|
1 | 1 | @use 'sass:map'; |
2 | 2 | @use '../../theming/theming'; |
3 | 3 |
|
| 4 | +@mixin _psuedo-checkbox-styles-with-color($text-color, $background) { |
| 5 | + .mat-pseudo-checkbox-checked, |
| 6 | + .mat-pseudo-checkbox-indeterminate { |
| 7 | + &.mat-pseudo-checkbox-minimal::after { |
| 8 | + color: $text-color; |
| 9 | + } |
| 10 | + |
| 11 | + // Full (checkbox) appearance inverts colors of text and background. |
| 12 | + &.mat-pseudo-checkbox-full { |
| 13 | + &::after { |
| 14 | + color: $background; |
| 15 | + } |
| 16 | + |
| 17 | + background: $text-color; |
| 18 | + } |
| 19 | + } |
| 20 | +} |
| 21 | + |
4 | 22 | @mixin color($config-or-theme) { |
5 | 23 | $config: theming.get-color-config($config-or-theme); |
6 | 24 | $is-dark-theme: map.get($config, is-dark); |
7 | | - $primary: map.get($config, primary); |
8 | | - $accent: map.get($config, accent); |
9 | | - $warn: map.get($config, warn); |
10 | | - $background: map.get($config, background); |
| 25 | + |
| 26 | + $primary: theming.get-color-from-palette(map.get($config, primary)); |
| 27 | + $accent: theming.get-color-from-palette(map.get($config, accent)); |
| 28 | + $warn: theming.get-color-from-palette(map.get($config, warn)); |
| 29 | + $background: theming.get-color-from-palette(map.get($config, background), background); |
| 30 | + $secondary-text: theming.get-color-from-palette(map.get($config, foreground), secondary-text); |
11 | 31 |
|
12 | 32 | // NOTE(traviskaufman): While the spec calls for translucent blacks/whites for disabled colors, |
13 | 33 | // this does not work well with elements layered on top of one another. To get around this we |
|
17 | 37 | $disabled-color: if($is-dark-theme, $white-30pct-opacity-on-dark, $black-26pct-opacity-on-light); |
18 | 38 | $colored-box-selector: '.mat-pseudo-checkbox-checked, .mat-pseudo-checkbox-indeterminate'; |
19 | 39 |
|
20 | | - .mat-pseudo-checkbox { |
21 | | - color: theming.get-color-from-palette(map.get($config, foreground), secondary-text); |
22 | | - |
23 | | - &::after { |
24 | | - color: theming.get-color-from-palette($background, background); |
| 40 | + .mat-pseudo-checkbox-full { |
| 41 | + color: $secondary-text; |
| 42 | + &.mat-pseudo-checkbox-disabled { |
| 43 | + color: $disabled-color; |
25 | 44 | } |
26 | 45 | } |
27 | 46 |
|
28 | | - .mat-pseudo-checkbox-disabled { |
29 | | - color: $disabled-color; |
30 | | - } |
31 | | - |
32 | | - .mat-primary .mat-pseudo-checkbox-checked, |
33 | | - .mat-primary .mat-pseudo-checkbox-indeterminate { |
34 | | - background: theming.get-color-from-palette(map.get($config, primary)); |
| 47 | + .mat-primary { |
| 48 | + @include _psuedo-checkbox-styles-with-color($primary, $background); |
35 | 49 | } |
36 | 50 |
|
37 | 51 | // Default to the accent color. Note that the pseudo checkboxes are meant to inherit the |
38 | 52 | // theme from their parent, rather than implementing their own theming, which is why we |
39 | 53 | // don't attach to the `mat-*` classes. Also note that this needs to be below `.mat-primary` |
40 | 54 | // in order to allow for the color to be overwritten if the checkbox is inside a parent that |
41 | 55 | // has `mat-accent` and is placed inside another parent that has `mat-primary`. |
42 | | - .mat-pseudo-checkbox-checked, |
43 | | - .mat-pseudo-checkbox-indeterminate, |
44 | | - .mat-accent .mat-pseudo-checkbox-checked, |
45 | | - .mat-accent .mat-pseudo-checkbox-indeterminate { |
46 | | - background: theming.get-color-from-palette(map.get($config, accent)); |
| 56 | + @include _psuedo-checkbox-styles-with-color($accent, $background); |
| 57 | + .mat-accent { |
| 58 | + @include _psuedo-checkbox-styles-with-color($accent, $background); |
47 | 59 | } |
48 | 60 |
|
49 | | - .mat-warn .mat-pseudo-checkbox-checked, |
50 | | - .mat-warn .mat-pseudo-checkbox-indeterminate { |
51 | | - background: theming.get-color-from-palette(map.get($config, warn)); |
| 61 | + .mat-warn { |
| 62 | + @include _psuedo-checkbox-styles-with-color($warn, $background); |
52 | 63 | } |
53 | 64 |
|
54 | | - .mat-pseudo-checkbox-checked, |
55 | | - .mat-pseudo-checkbox-indeterminate { |
56 | | - &.mat-pseudo-checkbox-disabled { |
| 65 | + .mat-pseudo-checkbox-disabled.mat-pseudo-checkbox-checked, |
| 66 | + .mat-pseudo-checkbox-disabled.mat-pseudo-checkbox-indeterminate { |
| 67 | + &.mat-pseudo-checkbox-minimal::after { |
| 68 | + color: $disabled-color; |
| 69 | + } |
| 70 | + |
| 71 | + &.mat-pseudo-checkbox-full { |
57 | 72 | background: $disabled-color; |
58 | 73 | } |
59 | 74 | } |
|
0 commit comments