|
| 1 | +@use 'sass:map'; |
1 | 2 | @use '@material/theme/theme-color' as mdc-theme-color;
|
2 | 3 | @use '@material/radio/radio-theme' as mdc-radio-theme;
|
3 | 4 | @use '@material/radio/radio' as mdc-radio;
|
|
6 | 7 | @use '../../material/core/typography/typography';
|
7 | 8 | @use '../../material/core/theming/theming';
|
8 | 9 |
|
| 10 | +@mixin _color-palette($color-palette) { |
| 11 | + @include mdc-radio-theme.theme(( |
| 12 | + selected-focus-icon-color: $color-palette, |
| 13 | + selected-focus-state-layer-color: $color-palette, |
| 14 | + selected-hover-icon-color: $color-palette, |
| 15 | + selected-hover-state-layer-color: $color-palette, |
| 16 | + selected-icon-color: $color-palette, |
| 17 | + selected-pressed-icon-color: $color-palette, |
| 18 | + selected-pressed-state-layer-color: $color-palette, |
| 19 | + )); |
| 20 | + |
| 21 | + // TODO(crisbeto): this should be included by MDC's `theme-styles`, but it isn't currently. |
| 22 | + @include mdc-radio-theme.focus-indicator-color($color-palette); |
| 23 | +} |
| 24 | + |
9 | 25 | @mixin color($config-or-theme) {
|
10 | 26 | $config: theming.get-color-config($config-or-theme);
|
11 |
| - // Save original values of MDC global variables. We need to save these so we can restore the |
12 |
| - // variables to their original values and prevent unintended side effects from using this mixin. |
13 |
| - $orig-baseline-theme-color: mdc-radio-theme.$baseline-theme-color; |
14 |
| - $orig-unchecked-color: mdc-radio-theme.$unchecked-color; |
15 |
| - $orig-disabled-circle-color: mdc-radio-theme.$disabled-circle-color; |
| 27 | + $primary: theming.get-color-from-palette(map.get($config, primary)); |
| 28 | + $accent: theming.get-color-from-palette(map.get($config, accent)); |
| 29 | + $warn: theming.get-color-from-palette(map.get($config, warn)); |
16 | 30 |
|
17 | 31 | @include mdc-helpers.mat-using-mdc-theme($config) {
|
18 |
| - mdc-radio-theme.$baseline-theme-color: primary; |
19 |
| - mdc-radio-theme.$unchecked-color: rgba(mdc-theme-color.prop-value(on-surface), 0.54); |
20 |
| - mdc-radio-theme.$disabled-circle-color: rgba(mdc-theme-color.prop-value(on-surface), 0.38); |
| 32 | + $on-surface: rgba(mdc-theme-color.$on-surface, 0.54); |
21 | 33 |
|
22 | 34 | .mat-mdc-radio-button {
|
23 | 35 | @include mdc-form-field.core-styles($query: mdc-helpers.$mat-theme-styles-query);
|
| 36 | + @include mdc-radio-theme.theme(( |
| 37 | + // The disabled colors don't use the `rgba` version, because |
| 38 | + // MDC applies a separate opacity to disabled buttons. |
| 39 | + disabled-selected-icon-color: mdc-theme-color.$on-surface, |
| 40 | + disabled-unselected-icon-color: mdc-theme-color.$on-surface, |
| 41 | + unselected-focus-icon-color: $on-surface, |
| 42 | + unselected-focus-state-layer-color: $on-surface, |
| 43 | + unselected-hover-icon-color: $on-surface, |
| 44 | + unselected-hover-state-layer-color: $on-surface, |
| 45 | + unselected-icon-color: $on-surface, |
| 46 | + unselected-pressed-icon-color: $on-surface, |
| 47 | + unselected-pressed-state-layer-color: $on-surface, |
| 48 | + )); |
24 | 49 |
|
25 | 50 | &.mat-primary {
|
26 |
| - @include mdc-radio.without-ripple($query: mdc-helpers.$mat-theme-styles-query); |
| 51 | + @include _color-palette($primary); |
27 | 52 | }
|
28 | 53 |
|
29 | 54 | &.mat-accent {
|
30 |
| - mdc-radio-theme.$baseline-theme-color: secondary; |
31 |
| - @include mdc-radio.without-ripple($query: mdc-helpers.$mat-theme-styles-query); |
| 55 | + @include _color-palette($accent); |
32 | 56 | }
|
33 | 57 |
|
34 | 58 | &.mat-warn {
|
35 |
| - mdc-radio-theme.$baseline-theme-color: error; |
36 |
| - @include mdc-radio.without-ripple($query: mdc-helpers.$mat-theme-styles-query); |
| 59 | + @include _color-palette($warn); |
37 | 60 | }
|
38 | 61 | }
|
39 | 62 | }
|
40 |
| - |
41 |
| - // Restore original values of MDC global variables. |
42 |
| - mdc-radio-theme.$baseline-theme-color: $orig-baseline-theme-color; |
43 |
| - mdc-radio-theme.$unchecked-color: $orig-unchecked-color; |
44 |
| - mdc-radio-theme.$disabled-circle-color: $orig-disabled-circle-color; |
45 | 63 | }
|
46 | 64 |
|
47 | 65 | @mixin typography($config-or-theme) {
|
|
0 commit comments