Skip to content

Commit

Permalink
refactor(material-experimental/mdc-select): remove dependency on @mat…
Browse files Browse the repository at this point in the history
…erial/select (#24148)

Cleans up the MDC-based select's theme by removing the dependency on `@material/select` and the variable overrides since we weren't including any of MDC's mixins.

(cherry picked from commit faf4b16)
  • Loading branch information
crisbeto authored and wagnermaciel committed Jan 7, 2022
1 parent eb508be commit 9b96999
Showing 1 changed file with 6 additions and 27 deletions.
33 changes: 6 additions & 27 deletions src/material-experimental/mdc-select/_select-theme.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@use '@material/theme/theme-color' as mdc-theme-color;
@use '@material/menu-surface' as mdc-menu-surface;
@use '@material/list/evolution-mixins' as mdc-list;
@use '@material/select' as mdc-select;
@use '@material/typography' as mdc-typography;
@use '../mdc-helpers/mdc-helpers';
@use '../../material/core/typography/typography';
Expand All @@ -15,38 +14,25 @@
@mixin color($config-or-theme) {
$config: theming.get-color-config($config-or-theme);

// Save original values of MDC global variables. We need to save these so we can restore the
// variables to their original values and prevent unintended side effects from using this mixin.
$orig-ink-color: mdc-select.$ink-color;
$orig-label-color: mdc-select.$label-color;
$orig-disabled-label-color: mdc-select.$disabled-label-color;
$orig-dropdown-icon-color: mdc-select.$dropdown-icon-color;
$orig-disabled-dropdown-icon-color: mdc-select.$disabled-dropdown-icon-color;

@include mdc-helpers.mat-using-mdc-theme($config) {
mdc-select.$ink-color: rgba(mdc-theme-color.prop-value(on-surface), 0.87);
mdc-select.$label-color: rgba(mdc-theme-color.prop-value(on-surface), 0.6);
mdc-select.$disabled-label-color: rgba(mdc-theme-color.prop-value(on-surface), 0.38);
mdc-select.$dropdown-icon-color: rgba(mdc-theme-color.prop-value(on-surface), 0.54);
mdc-select.$disabled-dropdown-icon-color: rgba(mdc-theme-color.prop-value(on-surface), 0.38);

$disabled-color: rgba(mdc-theme-color.prop-value(on-surface), 0.38);
@include mdc-menu-surface.core-styles(mdc-helpers.$mat-theme-styles-query);
@include mdc-list.without-ripple(mdc-helpers.$mat-theme-styles-query);

.mat-mdc-select-value {
color: mdc-select.$ink-color;
color: rgba(mdc-theme-color.prop-value(on-surface), 0.87);
}

.mat-mdc-select-placeholder {
color: mdc-select.$label-color;
color: rgba(mdc-theme-color.prop-value(on-surface), 0.6);
}

.mat-mdc-select-disabled .mat-mdc-select-value {
color: mdc-select.$disabled-label-color;
color: $disabled-color;
}

.mat-mdc-select-arrow {
color: mdc-select.$dropdown-icon-color;
color: rgba(mdc-theme-color.prop-value(on-surface), 0.54);
}

.mat-mdc-form-field {
Expand All @@ -69,17 +55,10 @@
}

.mat-mdc-select.mat-mdc-select-disabled .mat-mdc-select-arrow {
color: mdc-select.$disabled-dropdown-icon-color;
color: $disabled-color;
}
}
}

// Restore original values of MDC global variables.
mdc-select.$ink-color: $orig-ink-color;
mdc-select.$label-color: $orig-label-color;
mdc-select.$disabled-label-color: $orig-disabled-label-color;
mdc-select.$dropdown-icon-color: $orig-dropdown-icon-color;
mdc-select.$disabled-dropdown-icon-color: $orig-disabled-dropdown-icon-color;
}

@mixin typography($config-or-theme) {
Expand Down

0 comments on commit 9b96999

Please sign in to comment.