11@use ' sass:math' ;
22@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 ' ;
55@use ' ../core/style/vendor-prefixes' ;
66@use ' ../core/style/variables' ;
7+ @use ' ../core/tokens/token-utils' ;
8+ @use ' ../core/tokens/m2/mat/select' as tokens-mat-select ;
79
810$mat-select-arrow-size : 5px !default ;
911$mat-select-arrow-margin : 4px !default ;
@@ -13,15 +15,29 @@ $mat-select-placeholder-arrow-space: 2 *
1315$leading-width : 12px !default ;
1416$scale : 0.75 !default ;
1517
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);
2018
2119.mat-mdc-select {
2220 display : inline-block ;
2321 width : 100% ;
2422 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+ }
2541}
2642
2743.mat-mdc-select-trigger {
@@ -32,9 +48,15 @@ $scale: 0.75 !default;
3248 box-sizing : border-box ;
3349 width : 100% ;
3450
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+ }
3860 }
3961}
4062
@@ -72,6 +94,23 @@ $scale: 0.75 !default;
7294 height : $mat-select-arrow-size ;
7395 position : relative ;
7496
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+
75114 svg {
76115 fill : currentColor ;
77116 position : absolute ;
@@ -91,15 +130,27 @@ $scale: 0.75 !default;
91130 }
92131}
93132
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 );
97138 width : 100% ; // Ensures that the panel matches the overlay width.
98139 max-height : $mat-select-panel-max-height ;
99- position : static ; // MDC uses `absolute` by default which will throw off our positioning.
100140 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+ }
101153
102- @include mdc-list .list-base ($query : structure);
103154 @include cdk .high-contrast (active , off) {
104155 outline : solid 1px ;
105156 }
@@ -124,6 +175,11 @@ $scale: 0.75 !default;
124175 math .div (variables .$swift-ease-out-duration , 3 )
125176 variables .$swift-ease-out-timing-function ;
126177
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+
127183 ._mat-animation-noopable & {
128184 transition : none ;
129185 }
0 commit comments