Skip to content

Commit 2be9529

Browse files
refactor: CSS "condition" to SCSS condition (#4690)
* refactor: css condition to scss condition * auto update snapshots (#4691) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * refactor: futher clearified the selector and elements --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 51f8eb7 commit 2be9529

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

packages/components/src/styles/internal/_form-components.scss

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@use "sass:map";
22
@use "sass:string";
3+
@use "sass:list";
34
@use "@db-ux/core-foundations/build/styles/icons";
45
@use "@db-ux/core-foundations/build/styles/fonts";
56
@use "@db-ux/core-foundations/build/styles/variables";
@@ -9,6 +10,11 @@
910

1011
@forward "../visually-hidden";
1112

13+
// https://developer.mozilla.org/en-US/docs/Web/CSS/:read-only
14+
$valid-read-only-form-fields: input, textarea;
15+
// https://developer.mozilla.org/en-US/docs/Web/CSS/field-sizing
16+
$valid-field-sizing-form-fields: input, textarea;
17+
1218
$dropdown-icon-transition: transform variables.$db-transition-straight-emotional;
1319
$dropdown-icon-transform: rotate(-180deg);
1420

@@ -372,7 +378,7 @@ $input-valid-types:
372378
background-color: colors.$db-adaptive-bg-basic-transparent-semi-hovered;
373379
}
374380

375-
&:is(input, textarea) {
381+
@if list.index($valid-field-sizing-form-fields, $selector) {
376382
/* see https://developer.mozilla.org/en-US/docs/Web/CSS/field-sizing */
377383
&[data-field-sizing="content"] {
378384
field-sizing: content;
@@ -383,11 +389,13 @@ $input-valid-types:
383389
}
384390
}
385391

386-
&:is(input, textarea):not(:disabled):read-only {
387-
background-color: var(
388-
--db-textarea-read-only,
389-
#{colors.$db-adaptive-bg-basic-transparent-full-default}
390-
) !important;
392+
@if list.index($valid-read-only-form-fields, $selector) {
393+
&:not(:disabled):read-only {
394+
background-color: var(
395+
--db-#{$selector}-read-only,
396+
#{colors.$db-adaptive-bg-basic-transparent-full-default}
397+
) !important;
398+
}
391399
}
392400
}
393401

0 commit comments

Comments
 (0)