Skip to content

Commit 689ebbf

Browse files
committed
Add comment and use checked instead of "on" and "off"
1 parent f0ea517 commit 689ebbf

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

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

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
@import '../core/theming/theming';
33

44

5-
@mixin _md-slide-toggle-checked($palette, $thumb-on-hue) {
5+
@mixin _md-slide-toggle-checked($palette, $thumb-checked-hue) {
66
// Do not apply the checked colors if the toggle is disabled, because the specificity would be to high for
77
// the disabled styles.
88
&.md-checked:not(.md-disabled) {
99
.md-slide-toggle-thumb {
10-
background-color: md-color($palette, $thumb-on-hue);
10+
background-color: md-color($palette, $thumb-checked-hue);
1111
}
1212

1313
.md-slide-toggle-bar {
14-
background-color: md-color($palette, $thumb-on-hue, 0.5);
14+
background-color: md-color($palette, $thumb-checked-hue, 0.5);
1515
}
1616
}
1717
}
1818

1919
// TODO(jelbourn): remove this when the real ripple has been applied to slide-toggle.
20-
@mixin _md-slide-toggle-ripple($palette, $foreground, $thumb-on-hue) {
20+
@mixin _md-slide-toggle-ripple($palette, $foreground, $thumb-checked-hue) {
2121

2222
&.md-slide-toggle-focused {
2323
&:not(.md-checked) .md-ink-ripple {
@@ -27,7 +27,7 @@
2727
}
2828

2929
.md-ink-ripple {
30-
background-color: md-color($palette, $thumb-on-hue, 0.26);
30+
background-color: md-color($palette, $thumb-checked-hue, 0.26);
3131
}
3232
}
3333

@@ -41,24 +41,28 @@
4141
$background: map-get($theme, background);
4242
$foreground: map-get($theme, foreground);
4343

44-
$thumb-on-hue: if($is-dark, 200, 500);
45-
$thumb-off-hue: if($is-dark, 400, 50);
44+
// Color hues based on the specs, which prescribe different hues for dark and light themes
45+
// https://material.google.com/components/selection-controls.html#selection-controls-switch
46+
$thumb-normal-hue: if($is-dark, 400, 50);
47+
$thumb-checked-hue: if($is-dark, 200, 500);
4648
$thumb-disabled-hue: if($is-dark, 800, 400);
49+
50+
$bar-normal-color: md-color($foreground, disabled);
4751
$bar-disabled-color: if($is-dark, rgba(white, 0.12), rgba(black, 0.1));
4852

4953
md-slide-toggle {
50-
@include _md-slide-toggle-checked($accent, $thumb-on-hue);
51-
@include _md-slide-toggle-ripple($accent, $foreground, $thumb-on-hue);
54+
@include _md-slide-toggle-checked($accent, $thumb-checked-hue);
55+
@include _md-slide-toggle-ripple($accent, $foreground, $thumb-checked-hue);
5256

5357

5458
&.md-primary {
55-
@include _md-slide-toggle-checked($primary, $thumb-on-hue);
56-
@include _md-slide-toggle-ripple($primary, $foreground, $thumb-on-hue);
59+
@include _md-slide-toggle-checked($primary, $thumb-checked-hue);
60+
@include _md-slide-toggle-ripple($primary, $foreground, $thumb-checked-hue);
5761
}
5862

5963
&.md-warn {
60-
@include _md-slide-toggle-checked($warn, $thumb-on-hue);
61-
@include _md-slide-toggle-ripple($warn, $foreground, $thumb-on-hue);
64+
@include _md-slide-toggle-checked($warn, $thumb-checked-hue);
65+
@include _md-slide-toggle-ripple($warn, $foreground, $thumb-checked-hue);
6266
}
6367

6468
}
@@ -76,10 +80,10 @@
7680
}
7781

7882
.md-slide-toggle-thumb {
79-
background-color: md-color($md-grey, $thumb-off-hue);
83+
background-color: md-color($md-grey, $thumb-normal-hue);
8084
}
8185

8286
.md-slide-toggle-bar {
83-
background-color: md-color($foreground, disabled);
87+
background-color: $bar-normal-color;
8488
}
8589
}

0 commit comments

Comments
 (0)