1
1
@use ' sass:math' ;
2
2
@use ' @angular/cdk' ;
3
- @use ' @material/menu-surface ' as mdc-menu-surface ;
4
- @use ' @material/list/evolution-mixins ' as mdc-list ;
3
+ @use ' @material/typography/typography ' as mdc-typography ;
4
+ @use ' ../core/style/elevation ' ;
5
5
@use ' ../core/style/vendor-prefixes' ;
6
6
@use ' ../core/style/variables' ;
7
+ @use ' ../core/tokens/token-utils' ;
8
+ @use ' ../core/tokens/m2/mat/select' as tokens-mat-select ;
7
9
8
10
$mat-select-arrow-size : 5px !default ;
9
11
$mat-select-arrow-margin : 4px !default ;
@@ -13,15 +15,29 @@ $mat-select-placeholder-arrow-space: 2 *
13
15
$leading-width : 12px !default ;
14
16
$scale : 0.75 !default ;
15
17
16
- // We base the select panel styling on top of MDC's menu styles and we
17
- // implement the trigger ourselves since MDC doesn't provide an equivalent.
18
-
19
- @include mdc-menu-surface .core-styles ($query : structure);
20
18
21
19
.mat-mdc-select {
22
20
display : inline-block ;
23
21
width : 100% ;
24
22
outline : none ;
23
+
24
+ @include token-utils .use-tokens (
25
+ tokens-mat-select .$prefix , tokens-mat-select .get-token-slots ()) {
26
+ @include mdc-typography .smooth-font ();
27
+ @include token-utils .create-token-slot (color , enabled- trigger- color);
28
+ @include token-utils .create-token-slot (font-family , trigger- font);
29
+ @include token-utils .create-token-slot (line-height , trigger- line- height);
30
+ @include token-utils .create-token-slot (font-size , trigger- size);
31
+ @include token-utils .create-token-slot (font-weight , trigger- weight);
32
+ @include token-utils .create-token-slot (letter-spacing , trigger- tracking);
33
+ }
34
+ }
35
+
36
+ .mat-mdc-select-disabled {
37
+ @include token-utils .use-tokens (
38
+ tokens-mat-select .$prefix , tokens-mat-select .get-token-slots ()) {
39
+ @include token-utils .create-token-slot (color , disabled- trigger- color);
40
+ }
25
41
}
26
42
27
43
.mat-mdc-select-trigger {
@@ -32,9 +48,15 @@ $scale: 0.75 !default;
32
48
box-sizing : border-box ;
33
49
width : 100% ;
34
50
35
- .mat-mdc-select-disabled & {
36
- @include vendor-prefixes .user-select (none );
37
- cursor : default ;
51
+ @include token-utils .use-tokens (
52
+ tokens-mat-select .$prefix , tokens-mat-select .get-token-slots ()) {
53
+ @include token-utils .create-token-slot (color , enabled- trigger- color);
54
+
55
+ .mat-mdc-select-disabled & {
56
+ @include vendor-prefixes .user-select (none );
57
+ @include token-utils .create-token-slot (color , disabled- trigger- color);
58
+ cursor : default ;
59
+ }
38
60
}
39
61
}
40
62
@@ -72,6 +94,23 @@ $scale: 0.75 !default;
72
94
height : $mat-select-arrow-size ;
73
95
position : relative ;
74
96
97
+ @include token-utils .use-tokens (
98
+ tokens-mat-select .$prefix , tokens-mat-select .get-token-slots ()) {
99
+ @include token-utils .create-token-slot (color , enabled- arrow- color);
100
+
101
+ .mat-mdc-form-field.mat-focused & {
102
+ @include token-utils .create-token-slot (color , focused- arrow- color);
103
+ }
104
+
105
+ .mat-mdc-form-field .mat-mdc-select.mat-mdc-select-invalid & {
106
+ @include token-utils .create-token-slot (color , invalid- arrow- color);
107
+ }
108
+
109
+ .mat-mdc-form-field .mat-mdc-select.mat-mdc-select-disabled & {
110
+ @include token-utils .create-token-slot (color , disabled- arrow- color);
111
+ }
112
+ }
113
+
75
114
svg {
76
115
fill : currentColor ;
77
116
position : absolute ;
@@ -91,15 +130,27 @@ $scale: 0.75 !default;
91
130
}
92
131
}
93
132
94
- // Note that the `.mdc-menu-surface` is here in order to bump up the specificity
95
- // and avoid interference with `mat-menu` which uses the same mixins from MDC.
96
- .mdc-menu-surface.mat-mdc-select-panel {
133
+ // Even though we don't use the MDC styles, we need to keep the classes in the
134
+ // DOM for the Gmat versions to work. We need to bump up the specificity here
135
+ // so that it's higher than MDC's styles.
136
+ div .mat-mdc-select-panel {
137
+ @include elevation .elevation (8 );
97
138
width : 100% ; // Ensures that the panel matches the overlay width.
98
139
max-height : $mat-select-panel-max-height ;
99
- position : static ; // MDC uses `absolute` by default which will throw off our positioning.
100
140
outline : 0 ;
141
+ overflow : auto ;
142
+ padding : 8px 0 ;
143
+ border-radius : 4px ;
144
+ box-sizing : border-box ;
145
+
146
+ // Workaround in case other MDC menu surface styles bleed in.
147
+ position : static ;
148
+
149
+ @include token-utils .use-tokens (
150
+ tokens-mat-select .$prefix , tokens-mat-select .get-token-slots ()) {
151
+ @include token-utils .create-token-slot (background-color , panel- background- color);
152
+ }
101
153
102
- @include mdc-list .list-base ($query : structure);
103
154
@include cdk .high-contrast (active , off) {
104
155
outline : solid 1px ;
105
156
}
@@ -124,6 +175,11 @@ $scale: 0.75 !default;
124
175
math .div (variables .$swift-ease-out-duration , 3 )
125
176
variables .$swift-ease-out-timing-function ;
126
177
178
+ @include token-utils .use-tokens (
179
+ tokens-mat-select .$prefix , tokens-mat-select .get-token-slots ()) {
180
+ @include token-utils .create-token-slot (color , placeholder- color);
181
+ }
182
+
127
183
._mat-animation-noopable & {
128
184
transition : none ;
129
185
}
0 commit comments