forked from angular/components
/
_button-theme.scss
183 lines (161 loc) · 7.12 KB
/
_button-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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
@use '@material/button/button' as mdc-button;
@use '@material/button/button-theme' as mdc-button-theme;
@use '@material/ripple/ripple-theme' as mdc-ripple-theme;
@use '@material/theme/theme-color' as mdc-theme-color;
@use '@material/theme/theme' as mdc-theme;
@use '@material/elevation/elevation-theme' as mdc-elevation-theme;
@use '../../material/core/ripple/ripple-theme';
@use '../../material/core/typography/typography';
@use '../mdc-helpers/mdc-helpers';
@use '../../material/core/theming/theming';
@use './button-theme-private';
@mixin color($config-or-theme) {
$config: theming.get-color-config($config-or-theme);
@include mdc-helpers.mat-using-mdc-theme($config) {
// Add state interactions for hover, focus, press, active. Colors are changed based on
// the mixin mdc-states-base-color
.mat-mdc-button, .mat-mdc-raised-button, .mat-mdc-unelevated-button, .mat-mdc-outlined-button {
@include mdc-ripple-theme.states(
$query: mdc-helpers.$mat-theme-styles-query,
$ripple-target: button-theme-private.$button-state-target);
}
.mat-mdc-button, .mat-mdc-outlined-button {
&.mat-unthemed {
@include mdc-button-theme.ink-color(mdc-theme-color.$on-surface,
$query: mdc-helpers.$mat-theme-styles-query);
}
&.mat-primary {
@include mdc-button-theme.ink-color(primary, $query: mdc-helpers.$mat-theme-styles-query);
@include mdc-ripple-theme.states-base-color(primary,
$query: mdc-helpers.$mat-theme-styles-query,
$ripple-target: button-theme-private.$button-state-target);
@include button-theme-private.ripple-ink-color(primary);
}
&.mat-accent {
@include mdc-button-theme.ink-color(secondary, $query: mdc-helpers.$mat-theme-styles-query);
@include mdc-ripple-theme.states-base-color(secondary,
$query: mdc-helpers.$mat-theme-styles-query,
$ripple-target: button-theme-private.$button-state-target);
@include button-theme-private.ripple-ink-color(secondary);
}
&.mat-warn {
@include mdc-button-theme.ink-color(error, $query: mdc-helpers.$mat-theme-styles-query);
@include mdc-ripple-theme.states-base-color(error,
$query: mdc-helpers.$mat-theme-styles-query,
$ripple-target: button-theme-private.$button-state-target);
@include button-theme-private.ripple-ink-color(error);
}
}
.mat-mdc-raised-button,
.mat-mdc-unelevated-button {
&.mat-unthemed {
@include mdc-button-theme.container-fill-color(mdc-theme-color.$surface,
$query: mdc-helpers.$mat-theme-styles-query);
@include mdc-button-theme.ink-color(mdc-theme-color.$on-surface,
$query: mdc-helpers.$mat-theme-styles-query);
@include mdc-ripple-theme.states-base-color(mdc-theme-color.$on-surface,
$query: mdc-helpers.$mat-theme-styles-query,
$ripple-target: button-theme-private.$button-state-target);
}
&.mat-primary {
@include mdc-button-theme.container-fill-color(primary,
$query: mdc-helpers.$mat-theme-styles-query);
@include mdc-button-theme.ink-color(on-primary,
$query: mdc-helpers.$mat-theme-styles-query);
@include mdc-ripple-theme.states-base-color(on-primary,
$query: mdc-helpers.$mat-theme-styles-query,
$ripple-target: button-theme-private.$button-state-target);
@include button-theme-private.ripple-ink-color(on-primary);
}
&.mat-accent {
@include mdc-button-theme.container-fill-color(secondary,
$query: mdc-helpers.$mat-theme-styles-query);
@include mdc-button-theme.ink-color(on-secondary,
$query: mdc-helpers.$mat-theme-styles-query);
@include mdc-ripple-theme.states-base-color(on-secondary,
$query: mdc-helpers.$mat-theme-styles-query,
$ripple-target: button-theme-private.$button-state-target);
@include button-theme-private.ripple-ink-color(on-secondary);
}
&.mat-warn {
@include mdc-button-theme.container-fill-color(error,
$query: mdc-helpers.$mat-theme-styles-query);
@include mdc-button-theme.ink-color(on-error, $query: mdc-helpers.$mat-theme-styles-query);
@include mdc-ripple-theme.states-base-color(on-error,
$query: mdc-helpers.$mat-theme-styles-query,
$ripple-target: button-theme-private.$button-state-target);
@include button-theme-private.ripple-ink-color(on-error);
}
@include button-theme-private.apply-disabled-style() {
@include button-theme-private.apply-disabled-background();
}
}
.mat-mdc-outlined-button {
&.mat-unthemed {
@include mdc-button-theme.outline-color(mdc-theme-color.$on-surface,
$query: mdc-helpers.$mat-theme-styles-query);
}
&.mat-primary {
@include mdc-button-theme.outline-color(primary,
$query: mdc-helpers.$mat-theme-styles-query);
}
&.mat-accent {
@include mdc-button-theme.outline-color(secondary,
$query: mdc-helpers.$mat-theme-styles-query);
}
&.mat-warn {
@include mdc-button-theme.outline-color(error,
$query: mdc-helpers.$mat-theme-styles-query);
}
@include button-theme-private.apply-disabled-style() {
@include mdc-theme.prop(border-color,
mdc-theme-color.ink-color-for-fill_(disabled, mdc-theme-color.$background));
}
}
.mat-mdc-raised-button {
@include button-theme-private.apply-disabled-style() {
@include mdc-elevation-theme.elevation(0, $query: mdc-helpers.$mat-theme-styles-query);
}
}
.mat-mdc-button, .mat-mdc-raised-button, .mat-mdc-unelevated-button, .mat-mdc-outlined-button {
@include button-theme-private.apply-disabled-style() {
@include button-theme-private.apply-disabled-color();
}
}
@include mdc-button.without-ripple($query: mdc-helpers.$mat-theme-styles-query);
}
}
@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-button.without-ripple($query: mdc-helpers.$mat-typography-styles-query);
}
}
@mixin density($config-or-theme) {
$density-scale: theming.get-density-config($config-or-theme);
.mat-mdc-button,
.mat-mdc-raised-button,
.mat-mdc-unelevated-button,
.mat-mdc-outlined-button {
@include mdc-button-theme.density($density-scale, $query: mdc-helpers.$mat-base-styles-query);
@include button-theme-private.touch-target-density($density-scale);
}
}
@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-button') {
$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);
}
}
}