Skip to content

Commit 19c45c5

Browse files
authored
fix(material/slide-toggle): align colors with spec (#25792)
* fix(material/slide-toggle): align colors with spec Note: the disabled state still isn't 100% right. There seems to be some opacity interaction going on that prevents matching the spec perfectly. * fixup! fix(material/slide-toggle): align colors with spec
1 parent 46b2f08 commit 19c45c5

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
// Generates all color mapping for the properties that only change based on the theme.
1212
@function _get-theme-base-map($is-dark) {
1313
$on-surface: if($is-dark, mdc-color-palette.$grey-100, mdc-color-palette.$grey-800);
14-
$hairline: if($is-dark, mdc-color-palette.$grey-500, mdc-color-palette.$grey-300);
15-
$on-surface-variant: if($is-dark, mdc-color-palette.$grey-200, mdc-color-palette.$grey-700);
14+
$hairline: if($is-dark, mdc-color-palette.$grey-700, mdc-color-palette.$grey-300);
15+
$on-surface-variant: if($is-dark, mdc-color-palette.$grey-500, mdc-color-palette.$grey-700);
1616
$on-surface-state-content: if($is-dark, mdc-color-palette.$grey-50, mdc-color-palette.$grey-900);
17-
$disabled-handle-color: mdc-color-palette.$grey-800;
18-
$selected-icon-color: mdc-color-palette.$grey-100;
19-
$icon-color: if($is-dark, mdc-color-palette.$grey-800, mdc-color-palette.$grey-100);
17+
$disabled-handle-color: if($is-dark, #000, mdc-color-palette.$grey-800);
18+
$icon-color: if($is-dark, mdc-color-palette.$grey-900, #fff);
2019

2120
@return (
2221
disabled-selected-handle-color: $disabled-handle-color,
@@ -40,23 +39,24 @@
4039
handle-surface-color: surface,
4140
unselected-handle-color: $on-surface-variant,
4241

43-
selected-icon-color: $selected-icon-color,
42+
selected-icon-color: $icon-color,
4443
disabled-selected-icon-color: $icon-color,
4544
disabled-unselected-icon-color: $icon-color,
4645
unselected-icon-color: $icon-color,
4746
);
4847
}
4948

5049
// Generates the mapping for the properties that change based on the slide toggle color.
51-
@function _get-theme-color-map($color-palette) {
52-
$state-content: color.scale($color-palette, $blackness: 50%);
53-
$inverse: color.scale($color-palette, $lightness: 75%);
50+
@function _get-theme-color-map($color-palette, $is-dark) {
51+
$primary: theming.get-color-from-palette($color-palette, if($is-dark, 300, 600));
52+
$state-content: theming.get-color-from-palette($color-palette, if($is-dark, 200, 900));
53+
$inverse: theming.get-color-from-palette($color-palette, if($is-dark, 600, 300));
5454

5555
@return (
56-
selected-focus-state-layer-color: $color-palette,
57-
selected-handle-color: $color-palette,
58-
selected-hover-state-layer-color: $color-palette,
59-
selected-pressed-state-layer-color: $color-palette,
56+
selected-focus-state-layer-color: $primary,
57+
selected-handle-color: $primary,
58+
selected-hover-state-layer-color: $primary,
59+
selected-pressed-state-layer-color: $primary,
6060

6161
selected-focus-handle-color: $state-content,
6262
selected-hover-handle-color: $state-content,
@@ -71,9 +71,9 @@
7171

7272
@mixin color($config-or-theme) {
7373
$config: theming.get-color-config($config-or-theme);
74-
$primary: theming.get-color-from-palette(map.get($config, primary));
75-
$accent: theming.get-color-from-palette(map.get($config, accent));
76-
$warn: theming.get-color-from-palette(map.get($config, warn));
74+
$primary: map.get($config, primary);
75+
$accent: map.get($config, accent);
76+
$warn: map.get($config, warn);
7777
$is-dark: map.get($config, is-dark);
7878
$foreground: map.get($config, foreground);
7979

@@ -90,15 +90,15 @@
9090
}
9191

9292
&.mat-primary {
93-
@include mdc-switch-theme.theme(_get-theme-color-map($primary));
93+
@include mdc-switch-theme.theme(_get-theme-color-map($primary, $is-dark));
9494
}
9595

9696
&.mat-accent {
97-
@include mdc-switch-theme.theme(_get-theme-color-map($accent));
97+
@include mdc-switch-theme.theme(_get-theme-color-map($accent, $is-dark));
9898
}
9999

100100
&.mat-warn {
101-
@include mdc-switch-theme.theme(_get-theme-color-map($warn));
101+
@include mdc-switch-theme.theme(_get-theme-color-map($warn, $is-dark));
102102
}
103103
}
104104
}

0 commit comments

Comments
 (0)