Skip to content

Commit

Permalink
fix(material/slider): Move unthemable tokens to theme mixin (#27584)
Browse files Browse the repository at this point in the history
Though these tokens are not currently affected by the theme, in the
future they will be affected by the design system used for theming (M2
or M3)

BREAKING CHANGE:
There are new styles emitted by `mat.slider-theme` that are not
emitted by any of: `mat.slider-color`, `mat.slider-typography`,
`mat.slider-density`. If you rely on the partial mixins only and don't
call `mat.slider-theme`, you can add `mat.slider-base` to get the
missing styles.
  • Loading branch information
amysorto authored Aug 7, 2023
1 parent 32981cc commit c572dc4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/material/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
@forward './legacy-slider/slider-theme' as legacy-slider-* show legacy-slider-theme,
legacy-slider-color, legacy-slider-typography;
@forward './slider/slider-theme' as slider-* show slider-theme, slider-color, slider-typography,
slider-density;
slider-density, slider-base;
@forward './snack-bar/snack-bar-theme' as snack-bar-* show snack-bar-theme, snack-bar-color,
snack-bar-typography, snack-bar-density;
@forward './legacy-snack-bar/snack-bar-theme' as legacy-snack-bar-* show legacy-snack-bar-theme,
Expand Down
9 changes: 9 additions & 0 deletions src/material/slider/_slider-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@
@use '@material/slider/slider-theme' as mdc-slider-theme;
@use '../core/theming/theming';
@use '../core/typography/typography';
@use '../core/style/sass-utils';
@use '../core/tokens/token-utils';
@use '../core/tokens/m2/mat/slider' as m2-mat-slider;
@use '../core/tokens/m2/mdc/slider' as m2-mdc-slider;

@mixin base($config-or-theme) {
// Add default values for tokens not related to color, typography, or density.
@include sass-utils.current-selector-or-root() {
@include mdc-slider-theme.theme(m2-mdc-slider.get-unthemable-tokens());
}
}

@mixin color($config-or-theme) {
$config: theming.get-color-config($config-or-theme);
$is-dark: map.get($config, is-dark);
Expand Down Expand Up @@ -74,6 +82,7 @@
$density: theming.get-density-config($theme);
$typography: theming.get-typography-config($theme);

@include base($theme);
@if $color != null {
@include color($color);
}
Expand Down
3 changes: 0 additions & 3 deletions src/material/slider/slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ $mat-slider-horizontal-margin: 8px !default;
}
}

// Add default values for MDC slider tokens that aren't outputted by the theming API.
@include mdc-slider-theme.theme(m2-mdc-slider.get-unthemable-tokens());

display: inline-block;
box-sizing: border-box;
outline: none;
Expand Down

0 comments on commit c572dc4

Please sign in to comment.