-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Expand file tree
/
Copy pathselect.scss
More file actions
261 lines (216 loc) · 7.31 KB
/
select.scss
File metadata and controls
261 lines (216 loc) · 7.31 KB
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
@use 'sass:math';
@use '@angular/cdk';
@use '../core/style/vendor-prefixes';
@use '../core/style/variables';
@use '../core/tokens/token-utils';
@use './m3-select';
$mat-select-arrow-size: 5px !default;
$mat-select-arrow-margin: 4px !default;
$mat-select-panel-max-height: 275px !default;
$mat-select-placeholder-arrow-space: 2 *
($mat-select-arrow-size + $mat-select-arrow-margin);
$leading-width: 12px !default;
$scale: 0.75 !default;
$fallbacks: m3-select.get-tokens();
@keyframes _mat-select-enter {
from {
opacity: 0;
transform: scaleY(0.8);
}
to {
opacity: 1;
transform: none;
}
}
@keyframes _mat-select-exit {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.mat-mdc-select {
display: inline-block;
width: 100%;
outline: none;
@include vendor-prefixes.smooth-font();
color: token-utils.slot(select-enabled-trigger-text-color, $fallbacks);
font-family: token-utils.slot(select-trigger-text-font, $fallbacks);
line-height: token-utils.slot(select-trigger-text-line-height, $fallbacks);
font-size: token-utils.slot(select-trigger-text-size, $fallbacks);
font-weight: token-utils.slot(select-trigger-text-weight, $fallbacks);
letter-spacing: token-utils.slot(select-trigger-text-tracking, $fallbacks);
}
div.mat-mdc-select-panel {
box-shadow: token-utils.slot(select-container-elevation-shadow, $fallbacks);
}
.mat-mdc-select-disabled {
color: token-utils.slot(select-disabled-trigger-text-color, $fallbacks);
.mat-mdc-select-placeholder {
color: token-utils.slot(select-disabled-trigger-text-color, $fallbacks);
}
}
.mat-mdc-select-trigger {
display: inline-flex;
align-items: center;
cursor: pointer;
position: relative;
box-sizing: border-box;
width: 100%;
.mat-mdc-select-disabled & {
@include vendor-prefixes.user-select(none);
cursor: default;
}
}
.mat-mdc-select-value {
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.mat-mdc-select-value-text {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.mat-mdc-select-arrow-wrapper {
height: 24px;
flex-shrink: 0;
display: inline-flex;
align-items: center;
.mat-form-field-appearance-fill .mdc-text-field--no-label & {
transform: none;
}
}
.mat-mdc-form-field .mat-mdc-select.mat-mdc-select-invalid .mat-mdc-select-arrow,
.mat-form-field-invalid:not(.mat-form-field-disabled) .mat-mdc-form-field-infix::after {
color: token-utils.slot(select-invalid-arrow-color, $fallbacks);
}
.mat-mdc-select-arrow {
width: $mat-select-arrow-size * 2;
height: $mat-select-arrow-size;
position: relative;
color: token-utils.slot(select-enabled-arrow-color, $fallbacks);
.mat-mdc-form-field.mat-focused & {
color: token-utils.slot(select-focused-arrow-color, $fallbacks);
}
.mat-mdc-form-field .mat-mdc-select.mat-mdc-select-disabled & {
color: token-utils.slot(select-disabled-arrow-color, $fallbacks);
}
.mat-select-open & {
transform: rotate(180deg);
}
.mat-form-field-animations-enabled & {
transition: transform variables.$swift-linear-duration variables.$swift-linear-timing-function;
}
svg {
fill: currentColor;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
@include cdk.high-contrast {
// On Chromium browsers the `currentColor` blends in with the
// background for SVGs so we have to fall back to `CanvasText`.
fill: CanvasText;
.mat-mdc-select-disabled & {
fill: GrayText;
}
}
}
}
// Even though we don't use the MDC styles, we need to keep the classes in the
// DOM for the Gmat versions to work. We need to bump up the specificity here
// so that it's higher than MDC's styles.
div.mat-mdc-select-panel {
$border-radius: 4px;
width: 100%; // Ensures that the panel matches the overlay width.
max-height: $mat-select-panel-max-height;
outline: 0;
overflow: auto;
padding: 8px 0;
box-sizing: border-box;
transform-origin: top center;
border-radius: 0 0 $border-radius $border-radius;
// Necessary so the `offsetParent` of the nested `mat-option` is the
// panel which is required for scroll calculations (see #30974).
position: relative;
background-color: token-utils.slot(select-panel-background-color, $fallbacks);
.mat-mdc-select-panel-above & {
border-radius: $border-radius $border-radius 0 0;
transform-origin: bottom center;
}
@include cdk.high-contrast {
outline: solid 1px;
}
}
.mat-select-panel-animations-enabled {
animation: _mat-select-enter 120ms cubic-bezier(0, 0, 0.2, 1);
&.mat-select-panel-exit {
animation: _mat-select-exit 100ms linear;
}
}
.mat-mdc-select-placeholder {
// Delay the transition until the label has animated about a third of the way through, in
// order to prevent the placeholder from overlapping for a split second.
transition: color variables.$swift-ease-out-duration
math.div(variables.$swift-ease-out-duration, 3)
variables.$swift-ease-out-timing-function;
color: token-utils.slot(select-placeholder-text-color, $fallbacks);
.mat-mdc-form-field:not(.mat-form-field-animations-enabled) &,
._mat-animation-noopable & {
transition: none;
}
.mat-form-field-hide-placeholder & {
color: transparent;
// Overwrite browser specific CSS properties that can overwrite the `color` property.
// Some developers seem to use this approach to easily overwrite the placeholder / label color.
-webkit-text-fill-color: transparent;
// Remove the transition to prevent the placeholder
// from overlapping when the label comes back down.
transition: none;
// Prevents the '...' from showing on the parent element.
display: block;
}
}
// Our MDC form field implementation is based on the MDC text field which doesn't include styles
// for select. The select specific styles are not present as they don't use their text field as a
// container. Below are the styles to account for the select arrow icon at the end.
.mat-mdc-form-field-type-mat-select {
&:not(.mat-form-field-disabled) .mat-mdc-text-field-wrapper {
cursor: pointer;
}
&.mat-form-field-appearance-fill {
.mat-mdc-floating-label {
max-width: calc(100% - #{$mat-select-placeholder-arrow-space});
}
.mdc-floating-label--float-above {
$arrow-scale: math.div($mat-select-placeholder-arrow-space, $scale);
max-width: calc(100% / #{$scale} - #{$arrow-scale});
}
}
&.mat-form-field-appearance-outline {
.mdc-notched-outline__notch {
max-width: calc(100% - #{2 * ($mat-select-placeholder-arrow-space + $leading-width)});
}
.mdc-text-field--label-floating .mdc-notched-outline__notch {
max-width: calc(100% - #{$leading-width * 2});
}
}
}
// Used to prevent inline elements from collapsing if their text bindings
// become empty. This is preferrable to inserting a blank space, because the
// space can be read out by screen readers (see #21725).
.mat-mdc-select-min-line:empty::before {
content: ' ';
white-space: pre;
width: 1px;
display: inline-block;
// Prevents some browsers from rendering the element in high contrast mode. Use `visibility`
// instead of `opacity` since VoiceOver + Chrome still reads out the space with the latter.
visibility: hidden;
}
.mat-form-field-appearance-fill .mat-mdc-select-arrow-wrapper {
transform: token-utils.slot(select-arrow-transform, $fallbacks);
}