1 | @use 'sass:map';
|
---|
2 | @use '../../theming/theming';
|
---|
3 |
|
---|
4 | @mixin color($config-or-theme) {
|
---|
5 | $config: theming.get-color-config($config-or-theme);
|
---|
6 | $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);
|
---|
11 |
|
---|
12 | // NOTE(traviskaufman): While the spec calls for translucent blacks/whites for disabled colors,
|
---|
13 | // this does not work well with elements layered on top of one another. To get around this we
|
---|
14 | // blend the colors together based on the base color and the theme background.
|
---|
15 | $white-30pct-opacity-on-dark: #686868;
|
---|
16 | $black-26pct-opacity-on-light: #b0b0b0;
|
---|
17 | $disabled-color: if($is-dark-theme, $white-30pct-opacity-on-dark, $black-26pct-opacity-on-light);
|
---|
18 | $colored-box-selector: '.mat-pseudo-checkbox-checked, .mat-pseudo-checkbox-indeterminate';
|
---|
19 |
|
---|
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);
|
---|
25 | }
|
---|
26 | }
|
---|
27 |
|
---|
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));
|
---|
35 | }
|
---|
36 |
|
---|
37 | // Default to the accent color. Note that the pseudo checkboxes are meant to inherit the
|
---|
38 | // theme from their parent, rather than implementing their own theming, which is why we
|
---|
39 | // don't attach to the `mat-*` classes. Also note that this needs to be below `.mat-primary`
|
---|
40 | // in order to allow for the color to be overwritten if the checkbox is inside a parent that
|
---|
41 | // 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));
|
---|
47 | }
|
---|
48 |
|
---|
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));
|
---|
52 | }
|
---|
53 |
|
---|
54 | .mat-pseudo-checkbox-checked,
|
---|
55 | .mat-pseudo-checkbox-indeterminate {
|
---|
56 | &.mat-pseudo-checkbox-disabled {
|
---|
57 | background: $disabled-color;
|
---|
58 | }
|
---|
59 | }
|
---|
60 | }
|
---|
61 |
|
---|
62 | @mixin typography($config-or-theme) {}
|
---|
63 |
|
---|
64 | @mixin _density($config-or-theme) {}
|
---|
65 |
|
---|
66 | @mixin theme($theme-or-color-config) {
|
---|
67 | $theme: theming.private-legacy-get-theme($theme-or-color-config);
|
---|
68 | @include theming.private-check-duplicate-theme-styles($theme, 'mat-pseudo-checkbox') {
|
---|
69 | $color: theming.get-color-config($theme);
|
---|
70 | $density: theming.get-density-config($theme);
|
---|
71 | $typography: theming.get-typography-config($theme);
|
---|
72 |
|
---|
73 | @if $color != null {
|
---|
74 | @include color($color);
|
---|
75 | }
|
---|
76 | @if $density != null {
|
---|
77 | @include _density($density);
|
---|
78 | }
|
---|
79 | @if $typography != null {
|
---|
80 | @include typography($typography);
|
---|
81 | }
|
---|
82 | }
|
---|
83 | }
|
---|