|
1 | 1 | @use '../../theming/theming'; |
2 | 2 | @use '../../theming/inspection'; |
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 | | - } |
| 3 | +@use '../../style/sass-utils'; |
| 4 | +@use '../../tokens/token-utils'; |
| 5 | +@use '../../tokens/m2/mat/full-pseudo-checkbox' as tokens-mat-full-pseudo-checkbox; |
| 6 | +@use '../../tokens/m2/mat/minimal-pseudo-checkbox' as tokens-mat-minimal-pseudo-checkbox; |
| 7 | + |
| 8 | +@mixin _palette-styles($theme, $palette-name) { |
| 9 | + @include sass-utils.current-selector-or-root() { |
| 10 | + @include token-utils.create-token-values(tokens-mat-full-pseudo-checkbox.$prefix, |
| 11 | + tokens-mat-full-pseudo-checkbox.get-color-tokens($theme, $palette-name)); |
| 12 | + @include token-utils.create-token-values(tokens-mat-minimal-pseudo-checkbox.$prefix, |
| 13 | + tokens-mat-minimal-pseudo-checkbox.get-color-tokens($theme, $palette-name)); |
19 | 14 | } |
20 | 15 | } |
21 | 16 |
|
22 | | -@mixin base($theme) { |
23 | | - // TODO(mmalerba): Move pseudo checkbox base tokens here |
24 | | -} |
| 17 | +@mixin base($theme) {} |
25 | 18 |
|
26 | 19 | @mixin color($theme) { |
27 | | - $is-dark-theme: inspection.get-theme-type($theme) == dark; |
28 | | - $primary: inspection.get-theme-color($theme, primary); |
29 | | - $accent: inspection.get-theme-color($theme, accent); |
30 | | - $warn: inspection.get-theme-color($theme, warn); |
31 | | - $background: inspection.get-theme-color($theme, background, background); |
32 | | - $secondary-text: inspection.get-theme-color($theme, foreground, secondary-text); |
33 | | - |
34 | | - // NOTE(traviskaufman): While the spec calls for translucent blacks/whites for disabled colors, |
35 | | - // this does not work well with elements layered on top of one another. To get around this we |
36 | | - // blend the colors together based on the base color and the theme background. |
37 | | - $white-30pct-opacity-on-dark: #686868; |
38 | | - $black-26pct-opacity-on-light: #b0b0b0; |
39 | | - $disabled-color: if($is-dark-theme, $white-30pct-opacity-on-dark, $black-26pct-opacity-on-light); |
40 | | - $colored-box-selector: '.mat-pseudo-checkbox-checked, .mat-pseudo-checkbox-indeterminate'; |
41 | | - |
42 | | - .mat-pseudo-checkbox-full { |
43 | | - color: $secondary-text; |
44 | | - &.mat-pseudo-checkbox-disabled { |
45 | | - color: $disabled-color; |
46 | | - } |
47 | | - } |
48 | | - |
49 | 20 | .mat-primary { |
50 | | - @include _psuedo-checkbox-styles-with-color($primary, $background); |
| 21 | + @include _palette-styles($theme, primary); |
51 | 22 | } |
52 | 23 |
|
53 | 24 | // Default to the accent color. Note that the pseudo checkboxes are meant to inherit the |
54 | 25 | // theme from their parent, rather than implementing their own theming, which is why we |
55 | 26 | // don't attach to the `mat-*` classes. Also note that this needs to be below `.mat-primary` |
56 | 27 | // in order to allow for the color to be overwritten if the checkbox is inside a parent that |
57 | 28 | // has `mat-accent` and is placed inside another parent that has `mat-primary`. |
58 | | - @include _psuedo-checkbox-styles-with-color($accent, $background); |
| 29 | + @include _palette-styles($theme, accent); |
59 | 30 | .mat-accent { |
60 | | - @include _psuedo-checkbox-styles-with-color($accent, $background); |
| 31 | + @include _palette-styles($theme, accent); |
61 | 32 | } |
62 | 33 |
|
63 | 34 | .mat-warn { |
64 | | - @include _psuedo-checkbox-styles-with-color($warn, $background); |
65 | | - } |
66 | | - |
67 | | - .mat-pseudo-checkbox-disabled.mat-pseudo-checkbox-checked, |
68 | | - .mat-pseudo-checkbox-disabled.mat-pseudo-checkbox-indeterminate { |
69 | | - &.mat-pseudo-checkbox-minimal::after { |
70 | | - color: $disabled-color; |
71 | | - } |
72 | | - |
73 | | - &.mat-pseudo-checkbox-full { |
74 | | - background: $disabled-color; |
75 | | - } |
| 35 | + @include _palette-styles($theme, warn); |
76 | 36 | } |
77 | 37 | } |
78 | 38 |
|
79 | 39 | @mixin typography($theme) {} |
80 | 40 |
|
81 | | -@mixin _density($theme) {} |
| 41 | +@mixin density($theme) {} |
82 | 42 |
|
83 | 43 | @mixin theme($theme) { |
84 | 44 | @include theming.private-check-duplicate-theme-styles($theme, 'mat-pseudo-checkbox') { |
|
87 | 47 | @include color($theme); |
88 | 48 | } |
89 | 49 | @if inspection.theme-has($theme, density) { |
90 | | - @include _density($theme); |
| 50 | + @include density($theme); |
91 | 51 | } |
92 | 52 | @if inspection.theme-has($theme, typography) { |
93 | 53 | @include typography($theme); |
|
0 commit comments