Skip to content

refactor: CSS "condition" to SCSS condition #4690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 12, 2025
20 changes: 14 additions & 6 deletions packages/components/src/styles/internal/_form-components.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@use "sass:map";
@use "sass:string";
@use "sass:list";
@use "@db-ux/core-foundations/build/styles/icons";
@use "@db-ux/core-foundations/build/styles/fonts";
@use "@db-ux/core-foundations/build/styles/variables";
Expand All @@ -9,6 +10,11 @@

@forward "../visually-hidden";

// https://developer.mozilla.org/en-US/docs/Web/CSS/:read-only
$valid-read-only-form-fields: input, textarea;
// https://developer.mozilla.org/en-US/docs/Web/CSS/field-sizing
$valid-field-sizing-form-fields: input, textarea;

$dropdown-icon-transition: transform variables.$db-transition-straight-emotional;
$dropdown-icon-transform: rotate(-180deg);

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

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

&:is(input, textarea):not(:disabled):read-only {
background-color: var(
--db-textarea-read-only,
#{colors.$db-adaptive-bg-basic-transparent-full-default}
) !important;
@if list.index($valid-read-only-form-fields, $selector) {
&:not(:disabled):read-only {
background-color: var(
--db-#{$selector}-read-only,
#{colors.$db-adaptive-bg-basic-transparent-full-default}
) !important;
}
}
}

Expand Down
Loading