/
_radio-theme.scss
86 lines (74 loc) · 3.2 KB
/
_radio-theme.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
@use '@material/theme/theme-color' as mdc-theme-color;
@use '@material/radio/radio-theme' as mdc-radio-theme;
@use '@material/radio/radio' as mdc-radio;
@use '@material/form-field' as mdc-form-field;
@use '../mdc-helpers/mdc-helpers';
@use '../../material/core/typography/typography';
@use '../../material/core/theming/theming';
@mixin color($config-or-theme) {
$config: theming.get-color-config($config-or-theme);
// Save original values of MDC global variables. We need to save these so we can restore the
// variables to their original values and prevent unintended side effects from using this mixin.
$orig-baseline-theme-color: mdc-radio-theme.$baseline-theme-color;
$orig-unchecked-color: mdc-radio-theme.$unchecked-color;
$orig-disabled-circle-color: mdc-radio-theme.$disabled-circle-color;
@include mdc-helpers.mat-using-mdc-theme($config) {
mdc-radio-theme.$baseline-theme-color: primary;
mdc-radio-theme.$unchecked-color: rgba(mdc-theme-color.prop-value(on-surface), 0.54);
mdc-radio-theme.$disabled-circle-color: rgba(mdc-theme-color.prop-value(on-surface), 0.38);
.mat-mdc-radio-button {
@include mdc-form-field.core-styles($query: mdc-helpers.$mat-theme-styles-query);
&.mat-primary {
@include mdc-radio.without-ripple($query: mdc-helpers.$mat-theme-styles-query);
}
&.mat-accent {
mdc-radio-theme.$baseline-theme-color: secondary;
@include mdc-radio.without-ripple($query: mdc-helpers.$mat-theme-styles-query);
}
&.mat-warn {
mdc-radio-theme.$baseline-theme-color: error;
@include mdc-radio.without-ripple($query: mdc-helpers.$mat-theme-styles-query);
}
}
}
// Restore original values of MDC global variables.
mdc-radio-theme.$baseline-theme-color: $orig-baseline-theme-color;
mdc-radio-theme.$unchecked-color: $orig-unchecked-color;
mdc-radio-theme.$disabled-circle-color: $orig-disabled-circle-color;
}
@mixin typography($config-or-theme) {
$config: typography.private-typography-to-2018-config(
theming.get-typography-config($config-or-theme));
@include mdc-helpers.mat-using-mdc-typography($config) {
@include mdc-radio.without-ripple($query: mdc-helpers.$mat-typography-styles-query);
@include mdc-form-field.core-styles($query: mdc-helpers.$mat-typography-styles-query);
}
}
@mixin density($config-or-theme) {
$density-scale: theming.get-density-config($config-or-theme);
.mat-mdc-radio-button .mdc-radio {
@include mdc-radio-theme.density($density-scale, $query: mdc-helpers.$mat-base-styles-query);
}
@if ($density-scale == -2 or $density-scale == 'minimum') {
.mat-mdc-radio-touch-target {
display: none;
}
}
}
@mixin theme($theme-or-color-config) {
$theme: theming.private-legacy-get-theme($theme-or-color-config);
@include theming.private-check-duplicate-theme-styles($theme, 'mat-mdc-radio') {
$color: theming.get-color-config($theme);
$density: theming.get-density-config($theme);
$typography: theming.get-typography-config($theme);
@if $color != null {
@include color($color);
}
@if $density != null {
@include density($density);
}
@if $typography != null {
@include typography($typography);
}
}
}