Skip to content

Commit ed0a7aa

Browse files
committed
fix(material/slide-toggle): move state-layer-size token (#28397)
* Fix a bug where the state-layer-size token was being defined twice: once via get-unthemable-tokens and another time by our density mixin because we were calling mdc's density mixin instead of the theme mixin. (cherry picked from commit 2744a4c)
1 parent ab2ceab commit ed0a7aa

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/material/core/tokens/m2/mdc/_switch.scss

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@use '../../../style/elevation';
33
@use '../../../style/sass-utils';
44
@use '../../../theming/inspection';
5+
@use '../../../theming/theming';
56
@use '../../token-utils';
67

78
// The prefix used to generate the fully qualified name for tokens in this file.
@@ -40,8 +41,6 @@ $prefix: (mdc, switch);
4041
track-width: 36px,
4142
// Width and height of icon when unselected.
4243
unselected-icon-size: 18px,
43-
// The diameter of the handle ripple.
44-
state-layer-size: 40px,
4544
// Opacity of ripple when selected and focused.
4645
selected-focus-state-layer-opacity: 0.12,
4746
// Opacity of ripple when selected and on hover.
@@ -164,7 +163,17 @@ $prefix: (mdc, switch);
164163

165164
// Tokens that can be configured through Angular Material's density theming API.
166165
@function get-density-tokens($theme) {
167-
@return ();
166+
$scale: theming.clamp-density(inspection.get-theme-density($theme), -3);
167+
168+
@return (
169+
// The diameter of the handle ripple.
170+
state-layer-size: map.get((
171+
0: 40px,
172+
-1: 36px,
173+
-2: 32px,
174+
-3: 28px,
175+
), $scale)
176+
);
168177
}
169178

170179
// Combines the tokens generated by the above functions into a single map with placeholder values.

src/material/slide-toggle/_slide-toggle-theme.scss

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,8 @@
7272
@include _theme-from-tokens(inspection.get-theme-tokens($theme, density));
7373
}
7474
@else {
75-
$density-scale: inspection.get-theme-density($theme);
76-
7775
.mat-mdc-slide-toggle {
78-
@include mdc-switch-theme.theme(mdc-switch-theme.density($density-scale));
76+
@include mdc-switch-theme.theme(tokens-mdc-switch.get-density-tokens($theme));
7977
}
8078
}
8179
}

0 commit comments

Comments
 (0)