2
2
3
3
@use ' ../core/style/vendor-prefixes' ;
4
4
@use ' ../core/style/layout-common' ;
5
+ @use ' ../core/style/elevation' ;
6
+ @use ' ../core/tokens/token-utils' ;
7
+ @use ' ../core/tokens/m2/mat/legacy-button-toggle' as tokens-mat-legacy-button-toggle ;
8
+ @use ' ../core/tokens/m2/mat/standard-button-toggle' as tokens-mat-standard-button-toggle ;
5
9
6
10
$standard-padding : 0 12px !default ;
7
- $standard-border-radius : 4px !default ;
8
-
9
11
$legacy-padding : 0 16px !default ;
12
+
13
+ // TODO(crisbeto): these variables aren't used anymore and should be removed.
10
14
$legacy-height : 36px !default ;
15
+ $standard-border-radius : 4px !default ;
11
16
$legacy-border-radius : 2px !default ;
12
17
18
+ $_legacy-tokens : (
19
+ tokens-mat-legacy-button-toggle .$prefix ,
20
+ tokens-mat-legacy-button-toggle .get-token-slots ()
21
+ );
22
+
23
+ $_standard-tokens : (
24
+ tokens-mat-standard-button-toggle .$prefix ,
25
+ tokens-mat-standard-button-toggle .get-token-slots ()
26
+ );
27
+
13
28
.mat-button-toggle-standalone ,
14
29
.mat-button-toggle-group {
30
+ @include token-utils .create-token-values (
31
+ tokens-mat-legacy-button-toggle .$prefix ,
32
+ tokens-mat-legacy-button-toggle .get-unthemable-tokens ()
33
+ );
34
+
35
+ @include elevation .overridable-elevation (2 );
15
36
position : relative ;
16
37
display : inline-flex ;
17
38
flex-direction : row ;
18
39
white-space : nowrap ;
19
40
overflow : hidden ;
20
- border-radius : $legacy-border-radius ;
21
41
-webkit-tap-highlight-color : transparent ;
22
42
23
43
// Fixes the ripples not being clipped to the border radius on Safari.
24
44
transform : translateZ (0 );
25
45
46
+ @include token-utils .use-tokens ($_legacy-tokens ...) {
47
+ @include token-utils .create-token-slot (border-radius , shape);
48
+ }
49
+
26
50
@include cdk .high-contrast (active , off) {
27
51
outline : solid 1px ;
28
52
}
29
53
}
30
54
31
55
.mat-button-toggle-standalone.mat-button-toggle-appearance-standard ,
32
56
.mat-button-toggle-group-appearance-standard {
33
- border-radius : $standard-border-radius ;
57
+ @include token-utils .create-token-values (
58
+ tokens-mat-standard-button-toggle .$prefix ,
59
+ tokens-mat-standard-button-toggle .get-unthemable-tokens ()
60
+ );
61
+
62
+ @include token-utils .use-tokens ($_standard-tokens ...) {
63
+ @include token-utils .create-token-slot (border-radius , shape);
64
+ border : solid 1px var (#{token-utils .get-token-variable (divider-color )} );
65
+ }
66
+
67
+ & :not ([class *= ' mat-elevation-z' ]) {
68
+ box-shadow : none ;
69
+ }
34
70
35
71
@include cdk .high-contrast (active , off) {
36
72
outline : 0 ;
@@ -51,30 +87,99 @@ $legacy-border-radius: 2px !default;
51
87
white-space : nowrap ;
52
88
position : relative ;
53
89
90
+ @include token-utils .use-tokens ($_legacy-tokens ...) {
91
+ @include token-utils .create-token-slot (color , text- color);
92
+ @include token-utils .create-token-slot (font-family , text- font);
93
+
94
+ & .cdk-keyboard-focused .mat-button-toggle-focus-overlay {
95
+ @include token-utils .create-token-slot (opacity , focus- state- layer- opacity);
96
+ }
97
+ }
98
+
54
99
// Fixes SVG icons that get thrown off because of the `vertical-align` on the parent.
55
100
.mat-icon svg {
56
101
vertical-align : top ;
57
102
}
103
+ }
58
104
59
- & .cdk-keyboard-focused {
60
- .mat-button-toggle-focus-overlay {
61
- opacity : 1 ;
105
+ .mat-button-toggle-checked {
106
+ @include token-utils .use-tokens ($_legacy-tokens ...) {
107
+ @include token-utils .create-token-slot (color , selected- state- text- color);
108
+ @include token-utils .create-token-slot (background-color , selected- state- background- color);
109
+ }
110
+ }
111
+
112
+ .mat-button-toggle-disabled {
113
+ @include token-utils .use-tokens ($_legacy-tokens ...) {
114
+ @include token-utils .create-token-slot (color , disabled- state- text- color);
115
+ @include token-utils .create-token-slot (background-color , disabled- state- background- color);
116
+
117
+ & .mat-button-toggle-checked {
118
+ @include token-utils .create-token-slot (background-color ,
119
+ disabled- selected- state- background- color);
62
120
}
63
121
}
64
122
}
65
123
66
124
.mat-button-toggle-appearance-standard {
67
- & :not (.mat-button-toggle-disabled ):hover .mat-button-toggle-focus-overlay {
68
- opacity : 0.04 ;
69
- }
125
+ @include token-utils .create-token-values (
126
+ tokens-mat-standard-button-toggle .$prefix ,
127
+ tokens-mat-standard-button-toggle .get-unthemable-tokens ()
128
+ );
129
+
130
+ @include token-utils .use-tokens ($_standard-tokens ...) {
131
+ $divider-color : var (#{token-utils .get-token-variable (divider-color )} );
132
+ @include token-utils .create-token-slot (color , text- color);
133
+ @include token-utils .create-token-slot (background-color , background-color );
134
+ @include token-utils .create-token-slot (font-family , text- font);
70
135
71
- // Similar to components like the checkbox, slide-toggle and radio, we cannot show the focus
72
- // overlay for `.cdk-program-focused` because mouse clicks on the <label> element would be always
73
- // treated as programmatic focus. Note that it needs the extra `:not` in order to have more
74
- // specificity than the `:hover` above.
75
- // TODO(paul): support `program` as well. See https://github.com/angular/components/issues/9889
76
- & .cdk-keyboard-focused :not (.mat-button-toggle-disabled ) .mat-button-toggle-focus-overlay {
77
- opacity : 0.12 ;
136
+ .mat-button-toggle-group-appearance-standard & + & {
137
+ border-left : solid 1px $divider-color ;
138
+ }
139
+
140
+ [dir = ' rtl' ] .mat-button-toggle-group-appearance-standard & + & {
141
+ border-left : none ;
142
+ border-right : solid 1px $divider-color ;
143
+ }
144
+
145
+ .mat-button-toggle-group-appearance-standard.mat-button-toggle-vertical & + & {
146
+ border-left : none ;
147
+ border-right : none ;
148
+ border-top : solid 1px $divider-color ;
149
+ }
150
+
151
+ & .mat-button-toggle-checked {
152
+ @include token-utils .create-token-slot (color , selected- state- text- color);
153
+ @include token-utils .create-token-slot (background-color , selected- state- background- color);
154
+ }
155
+
156
+ & .mat-button-toggle-disabled {
157
+ @include token-utils .create-token-slot (color , disabled- state- text- color);
158
+ @include token-utils .create-token-slot (background-color , disabled- state- background- color);
159
+
160
+ & .mat-button-toggle-checked {
161
+ @include token-utils .create-token-slot (color , disabled- selected- state- text- color);
162
+ @include token-utils .create-token-slot (background-color ,
163
+ disabled- selected- state- background- color);
164
+ }
165
+ }
166
+
167
+ .mat-button-toggle-focus-overlay {
168
+ @include token-utils .create-token-slot (background-color , state- layer- color);
169
+ }
170
+
171
+ & :not (.mat-button-toggle-disabled ):hover .mat-button-toggle-focus-overlay {
172
+ @include token-utils .create-token-slot (opacity , hover- state- layer- opacity);
173
+ }
174
+
175
+ // Similar to components like the checkbox, slide-toggle and radio, we cannot show the focus
176
+ // overlay for `.cdk-program-focused` because mouse clicks on the <label> element would be
177
+ // always treated as programmatic focus. Note that it needs the extra `:not` in order to have
178
+ // more specificity than the `:hover` above.
179
+ // TODO(paul): support `program` as well. See https://github.com/angular/components/issues/9889
180
+ & .cdk-keyboard-focused :not (.mat-button-toggle-disabled ) .mat-button-toggle-focus-overlay {
181
+ @include token-utils .create-token-slot (opacity , focus- state- layer- opacity);
182
+ }
78
183
}
79
184
80
185
// On touch devices the hover state will linger on the element after the user has tapped.
@@ -91,14 +196,21 @@ $legacy-border-radius: 2px !default;
91
196
.mat-button-toggle-label-content {
92
197
@include vendor-prefixes .user-select (none );
93
198
display : inline-block ;
94
- line-height : $legacy-height ;
95
199
padding : $legacy-padding ;
96
200
201
+ @include token-utils .use-tokens ($_legacy-tokens ...) {
202
+ @include token-utils .create-token-slot (line-height , height );
203
+ }
204
+
97
205
// Prevents IE from shifting the content on click.
98
206
position : relative ;
99
207
100
208
.mat-button-toggle-appearance-standard & {
101
209
padding : $standard-padding ;
210
+
211
+ @include token-utils .use-tokens ($_standard-tokens ...) {
212
+ @include token-utils .create-token-slot (line-height , height );
213
+ }
102
214
}
103
215
}
104
216
@@ -114,6 +226,10 @@ $legacy-border-radius: 2px !default;
114
226
// Disable pointer events to prevent it from hijacking user events.
115
227
pointer-events : none ;
116
228
opacity : 0 ;
229
+
230
+ @include token-utils .use-tokens ($_legacy-tokens ...) {
231
+ @include token-utils .create-token-slot (background-color , state- layer- color);
232
+ }
117
233
}
118
234
119
235
@include cdk .high-contrast (active , off) {
@@ -122,7 +238,7 @@ $legacy-border-radius: 2px !default;
122
238
// It uses a border, because the browser will render it using a brighter color.
123
239
.mat-button-toggle-checked {
124
240
.mat-button-toggle-focus-overlay {
125
- border-bottom : solid $legacy-height ;
241
+ border-bottom : solid 500 px ;
126
242
opacity : 0.5 ;
127
243
height : 0 ;
128
244
}
0 commit comments