1
1
@use ' sass:map' ;
2
+ @use ' ../mdc-helpers/mdc-helpers' ;
2
3
@use ' ../../material/core/theming/theming' ;
3
4
@use ' ../../cdk/a11y' ;
4
5
@use ' ../../material/core/theming/palette' ;
6
+ @use ' @material/theme/theme-color' as mdc-theme-color ;
5
7
6
8
// Width of the Material Design form-field select arrow.
7
9
$mat-form-field-select-arrow-width : 10px ;
@@ -68,7 +70,6 @@ $mat-form-field-select-horizontal-end-padding: $mat-form-field-select-arrow-widt
68
70
border-right : ($mat-form-field-select-arrow-width / 2 ) solid transparent ;
69
71
border-top : $mat-form-field-select-arrow-height solid ;
70
72
position : absolute ;
71
- top : 50% ;
72
73
right : 0 ;
73
74
74
75
// Make the arrow non-clickable so the user can click on the form control under it.
@@ -92,20 +93,64 @@ $mat-form-field-select-horizontal-end-padding: $mat-form-field-select-arrow-widt
92
93
}
93
94
}
94
95
96
+ // Gets the color to use for some text that is highlighted while a select has focus.
97
+ @function _get-focused-arrow-color ($palette ) {
98
+ @return rgba (mdc-theme-color .prop-value ($palette ), 0.87 );
99
+ }
100
+
95
101
@mixin private-form-field-native-select-color ($config ) {
96
- select .mat-mdc-input-element {
97
- // On dark themes we set the native `select` color to some shade of white,
98
- // however the color propagates to all of the `option` elements, which are
99
- // always on a white background inside the dropdown, causing them to blend in.
100
- // Since we can't change background of the dropdown, we need to explicitly
101
- // reset the color of the options to something dark.
102
- @if (map .get ($config , is-dark )) {
103
- option {
104
- color : palette .$dark-primary-text ;
102
+ @include mdc-helpers .mat-using-mdc-theme ($config ) {
103
+ // These values are taken from the MDC select implementation:
104
+ // https://github.com/material-components/material-components-web/blob/master/packages/mdc-select/_select-theme.scss
105
+ $dropdown-icon-color : rgba (mdc-theme-color .prop-value (on-surface ), 0.54 );
106
+ $disabled-dropdown-icon-color : rgba (mdc-theme-color .prop-value (on-surface ), 0.38 );
107
+
108
+ select .mat-mdc-input-element {
109
+ // On dark themes we set the native `select` color to some shade of white,
110
+ // however the color propagates to all of the `option` elements, which are
111
+ // always on a white background inside the dropdown, causing them to blend in.
112
+ // Since we can't change background of the dropdown, we need to explicitly
113
+ // reset the color of the options to something dark.
114
+ @if (map .get ($config , is-dark )) {
115
+ option {
116
+ color : palette .$dark-primary-text ;
117
+ }
118
+
119
+ option :disabled {
120
+ color : palette .$dark-disabled-text ;
121
+ }
122
+ }
123
+ }
124
+
125
+ .mat-mdc-form-field-type-mat-native-select {
126
+ .mat-mdc-form-field-infix ::after {
127
+ color : $dropdown-icon-color ;
105
128
}
106
129
107
- option :disabled {
108
- color : palette .$dark-disabled-text ;
130
+ & .mat-focused {
131
+ & .mat-primary {
132
+ .mat-mdc-form-field-infix ::after {
133
+ color : _get-focused-arrow-color (primary );
134
+ }
135
+ }
136
+
137
+ & .mat-accent {
138
+ .mat-mdc-form-field-infix ::after {
139
+ color : _get-focused-arrow-color (secondary );
140
+ }
141
+ }
142
+
143
+ & .mat-warn {
144
+ .mat-mdc-form-field-infix ::after {
145
+ color : _get-focused-arrow-color (error );
146
+ }
147
+ }
148
+ }
149
+
150
+ & .mat-form-field-disabled {
151
+ .mat-mdc-form-field-infix ::after {
152
+ color : $disabled-dropdown-icon-color ;
153
+ }
109
154
}
110
155
}
111
156
}
0 commit comments