|
11 | 11 | }
|
12 | 12 |
|
13 | 13 | .mat-slide-toggle-bar {
|
14 |
| - background-color: mat-color($palette, $thumb-checked-hue, 0.5); |
| 14 | + // Opacity is determined from the specs for the selection controls. |
| 15 | + // See: https://material.io/design/components/selection-controls.html#specs |
| 16 | + background-color: mat-color($palette, $thumb-checked-hue, 0.54); |
15 | 17 | }
|
16 |
| - } |
17 |
| -} |
18 | 18 |
|
19 |
| -// Applies the specified colors to the slide-toggle ripple elements. |
20 |
| -@mixin _mat-slide-toggle-ripple($palette, $ripple-unchecked-color, $ripple-checked-color) { |
21 |
| - &:not(.mat-checked) .mat-ripple-element { |
22 |
| - background-color: $ripple-unchecked-color; |
23 |
| - } |
24 |
| - .mat-ripple-element { |
25 |
| - background-color: $ripple-checked-color; |
| 19 | + .mat-ripple-element { |
| 20 | + // Set no opacity for the ripples because the ripple opacity will be adjusted dynamically |
| 21 | + // based on the type of interaction with the slide-toggle (e.g. for hover, focus) |
| 22 | + background-color: mat-color($palette, $thumb-checked-hue); |
| 23 | + } |
26 | 24 | }
|
27 | 25 | }
|
28 | 26 |
|
|
34 | 32 | $background: map-get($theme, background);
|
35 | 33 | $foreground: map-get($theme, foreground);
|
36 | 34 |
|
37 |
| - // Color hues based on the specs, which prescribe different hues for dark and light themes |
38 |
| - // https://material.google.com/components/selection-controls.html#selection-controls-switch |
39 |
| - $thumb-normal-hue: if($is-dark, 400, 50); |
40 |
| - $thumb-checked-hue: if($is-dark, 200, 500); |
| 35 | + // Color hues are based on the specs which briefly show the hues that are applied to a switch. |
| 36 | + // The 2018 specs no longer describe how dark switches should look like. Due to the lack of |
| 37 | + // information for dark themed switches, we keep the old behavior that is based on the previous |
| 38 | + // specifications. See: https://material.io/design/components/selection-controls.html#specs |
| 39 | + $thumb-unchecked-hue: if($is-dark, 400, 50); |
| 40 | + $thumb-checked-hue: if($is-dark, 200, default); |
41 | 41 | $thumb-disabled-hue: if($is-dark, 800, 400);
|
42 | 42 |
|
43 |
| - $bar-normal-color: mat-color($foreground, disabled); |
| 43 | + $bar-unchecked-color: mat-color($foreground, disabled); |
44 | 44 | $bar-disabled-color: if($is-dark, rgba(white, 0.12), rgba(black, 0.1));
|
45 | 45 |
|
46 |
| - // Ripple colors are based on the current palette and the state of the slide-toggle. |
47 |
| - // See https://material.google.com/components/selection-controls.html#selection-controls-switch |
48 | 46 | $ripple-unchecked-color: mat-color($foreground, base);
|
49 |
| - $ripple-primary-color: mat-color($primary, $thumb-checked-hue); |
50 |
| - $ripple-accent-color: mat-color($accent, $thumb-checked-hue); |
51 |
| - $ripple-warn-color: mat-color($warn, $thumb-checked-hue); |
52 | 47 |
|
53 | 48 | .mat-slide-toggle {
|
54 | 49 | @include _mat-slide-toggle-checked($accent, $thumb-checked-hue);
|
55 |
| - @include _mat-slide-toggle-ripple($accent, $ripple-unchecked-color, $ripple-accent-color); |
56 | 50 |
|
57 | 51 | &.mat-primary {
|
58 | 52 | @include _mat-slide-toggle-checked($primary, $thumb-checked-hue);
|
59 |
| - @include _mat-slide-toggle-ripple($accent, $ripple-unchecked-color, $ripple-primary-color); |
60 | 53 | }
|
61 | 54 |
|
62 | 55 | &.mat-warn {
|
63 | 56 | @include _mat-slide-toggle-checked($warn, $thumb-checked-hue);
|
64 |
| - @include _mat-slide-toggle-ripple($accent, $ripple-unchecked-color, $ripple-warn-color); |
65 | 57 | }
|
66 | 58 |
|
| 59 | + &:not(.mat-checked) .mat-ripple-element { |
| 60 | + // Set no opacity for the ripples because the ripple opacity will be adjusted dynamically |
| 61 | + // based on the type of interaction with the slide-toggle (e.g. for hover, focus) |
| 62 | + background-color: $ripple-unchecked-color; |
| 63 | + } |
67 | 64 | }
|
68 | 65 |
|
69 | 66 | .mat-disabled {
|
|
79 | 76 | }
|
80 | 77 |
|
81 | 78 | .mat-slide-toggle-thumb {
|
82 |
| - background-color: mat-color($mat-grey, $thumb-normal-hue); |
| 79 | + background-color: mat-color($mat-grey, $thumb-unchecked-hue); |
83 | 80 | }
|
84 | 81 |
|
85 | 82 | .mat-slide-toggle-bar {
|
86 |
| - background-color: $bar-normal-color; |
| 83 | + background-color: $bar-unchecked-color; |
87 | 84 | }
|
88 | 85 | }
|
89 | 86 |
|
|
0 commit comments