-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy path_select-input.scss
More file actions
303 lines (257 loc) · 11.3 KB
/
_select-input.scss
File metadata and controls
303 lines (257 loc) · 11.3 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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
// Select
.select-input {
@extend %text-item-common;
--#{$prefix}text-input-min-width: #{px-to-rem($ouds-select-input-size-min-width)};
--#{$prefix}text-input-min-height: #{px-to-rem($ouds-text-input-size-min-height)};
&.component-max-width {
max-width: px-to-rem($ouds-text-input-size-max-width);
}
}
.select-input-field {
position: absolute;
inset: 0;
width: 100%; // Avoid a bug on FF 125 and less
padding-top: calc(var(--#{$prefix}text-input-padding-y) - var(--#{$prefix}text-input-border-width-top) + var(--#{$prefix}font-size-label-small) * var(--#{$prefix}font-line-height-label-small));
padding-right: calc(var(--#{$prefix}text-input-trailing-action-padding-right) - var(--#{$prefix}text-input-border-width-right) + var(--#{$prefix}text-input-column-gap) + var(--#{$prefix}text-input-trailing-action-width));
padding-bottom: calc(var(--#{$prefix}text-input-padding-y) - var(--#{$prefix}text-input-border-width-bottom));
padding-left: calc(var(--#{$prefix}text-input-padding-x) - var(--#{$prefix}text-input-border-width-left));
font-weight: $ouds-font-weight-system-web-moderate;
color: $ouds-color-content-default;
appearance: none;
background-color: var(--#{$prefix}text-input-background-color);
border-color: var(--#{$prefix}text-input-border-color);
border-style: solid;
border-width: var(--#{$prefix}text-input-border-width-top) var(--#{$prefix}text-input-border-width-right) var(--#{$prefix}text-input-border-width-bottom) var(--#{$prefix}text-input-border-width-left);
@include border-radius(var(--#{$prefix}text-input-border-radius), 0);
&:hover {
--#{$prefix}text-input-background-color: #{$ouds-color-action-support-hover};
--#{$prefix}text-input-border-color: #{$ouds-text-input-color-border-hover};
}
&:focus-visible {
--#{$prefix}text-input-border-width-bottom: #{$ouds-text-input-border-width-focus};
--#{$prefix}text-input-background-color: #{$ouds-color-action-support-focus};
--#{$prefix}text-input-border-color: #{$ouds-text-input-color-border-focus};
// To avoid different behavior between browsers
// Chrome considers select as an input and doesn't make any difference between focus and focus-visible
// Firefox considers select as an element and does make a difference between focus and focus-visible
outline: 0;
box-shadow: none;
}
// Forgive Safari's selectors list
&:is(:open, :active) {
--#{$prefix}text-input-border-width-bottom: #{$ouds-text-input-border-width-focus};
--#{$prefix}text-input-background-color: #{$ouds-color-action-support-pressed};
--#{$prefix}text-input-border-color: #{$ouds-text-input-color-border-focus};
}
&:disabled:where(:not(.loading-indeterminate, .loading-determinate)) {
--#{$prefix}text-input-background-color: #{$ouds-color-action-support-disabled};
--#{$prefix}text-input-border-color: #{$ouds-color-action-disabled};
color: $ouds-color-action-disabled;
}
&:disabled {
pointer-events: none;
}
}
.select-input-field:is(:user-invalid, [aria-invalid="true"]) {
--#{$prefix}text-input-background-color: #{$ouds-color-surface-status-negative-muted};
--#{$prefix}text-input-border-color: #{$ouds-color-action-negative-enabled};
padding-right: calc(var(--#{$prefix}text-input-trailing-action-padding-right) - var(--#{$prefix}text-input-border-width-right) + var(--#{$prefix}text-input-column-gap) + var(--#{$prefix}text-input-trailing-action-width) + var(--#{$prefix}text-input-column-gap-trailing-error) + px-to-rem($ouds-button-size-icon-only));
&:hover {
--#{$prefix}text-input-border-color: #{$ouds-color-action-negative-hover};
}
&:focus-visible {
--#{$prefix}text-input-border-color: #{$ouds-color-action-negative-focus};
}
// Forgive Safari's selectors list
&:is(:open, :active) {
--#{$prefix}text-input-border-color: #{$ouds-color-action-negative-pressed};
}
}
.select-input-container {
position: relative;
min-width: var(--#{$prefix}text-input-min-width);
min-height: var(--#{$prefix}text-input-min-height);
padding-top: calc(var(--#{$prefix}text-input-padding-y) - var(--#{$prefix}text-input-border-width-top));
padding-right: calc(var(--#{$prefix}text-input-trailing-action-padding-right) - var(--#{$prefix}text-input-border-width-right));
padding-bottom: calc(var(--#{$prefix}text-input-padding-y) - var(--#{$prefix}text-input-border-width-bottom));
padding-left: calc(var(--#{$prefix}text-input-padding-x) - var(--#{$prefix}text-input-border-width-left));
color: $ouds-color-content-muted;
@include get-font-size("label-large");
&::after {
position: absolute;
top: 50%;
right: calc(var(--#{$prefix}text-input-trailing-action-padding-right) + $ouds-button-space-inset-icon-only);
display: block;
width: px-to-rem($ouds-button-size-icon-only);
height: px-to-rem($ouds-button-size-icon-only);
pointer-events: none;
content: "";
background-color: var(--#{$prefix}color-content-default);
mask: $select-input-chevron no-repeat 50% / px-to-rem($ouds-button-size-icon-only);
transform: translate(0, -50%);
}
// Leading icon
> img,
> svg {
position: absolute;
top: calc(var(--#{$prefix}text-input-min-height) / 2 - var(--#{$prefix}text-input-icon-size) / 2 - var(--#{$prefix}text-input-border-width-top));
left: calc(var(--#{$prefix}text-input-padding-x) - var(--#{$prefix}text-input-border-width-left));
z-index: 2;
width: var(--#{$prefix}text-input-icon-size);
min-width: var(--#{$prefix}text-input-icon-size);
height: var(--#{$prefix}text-input-icon-size);
color: var(--#{$prefix}color-content-muted);
pointer-events: none;
}
> label {
position: absolute;
top: 50%;
z-index: 1;
width: calc(100% - var(--#{$prefix}text-input-trailing-action-padding-right) - var(--#{$prefix}text-input-padding-x) - var(--#{$prefix}text-input-trailing-action-width) - var(--#{$prefix}text-input-column-gap));
max-height: 100%;
overflow: hidden;
text-overflow: ellipsis;
pointer-events: none;
transform: translate(0, -50%);
@include transition(font-size .15s ease-in-out, top .15s ease-out);
}
&:has(> svg:not(.loader)),
&:has(> img) {
> .select-input-field {
padding-left: calc(var(--#{$prefix}text-input-icon-size) + var(--#{$prefix}text-input-column-gap) + var(--#{$prefix}text-input-padding-x) - var(--#{$prefix}text-input-border-width-left));
}
> label {
padding-left: calc(var(--#{$prefix}text-input-icon-size) + var(--#{$prefix}text-input-column-gap));
}
}
&:has(:open)::after {
mask-image: $select-input-expanded-chevron;
}
&:has(.select-input-field:disabled:where(:not(.loading-indeterminate, .loading-determinate))) {
color: $ouds-color-action-disabled;
&::after {
background-color: $ouds-color-content-disabled;
}
}
&:has(.select-input-field:disabled) {
> label {
pointer-events: none;
}
}
// Forgive Safari's selectors list
&:is(:has(:open), :not(:has(:disabled:checked))) {
> label {
top: calc(var(--#{$prefix}text-input-padding-y) + .5 * (var(--#{$prefix}font-size-label-small) * var(--#{$prefix}font-line-height-label-small)) + .5 * (var(--#{$prefix}text-input-min-height) - 2 * var(--#{$prefix}text-input-padding-y) - var(--#{$prefix}font-size-label-small) * var(--#{$prefix}font-line-height-label-small) - var(--#{$prefix}font-size-label-large) * var(--#{$prefix}font-line-height-label-large)));
white-space: nowrap;
@include get-font-size("label-small");
}
}
.loader {
position: absolute;
top: 50%;
right: calc(var(--#{$prefix}text-input-trailing-action-padding-right) + $ouds-button-space-inset-icon-only);
left: auto;
display: none;
width: px-to-rem($ouds-button-size-loader);
height: px-to-rem($ouds-button-size-loader);
pointer-events: none;
transform: translate(0, -50%) rotate(-90deg);
> .loader-inner {
fill: none;
stroke: var(--#{$prefix}color-content-default);
stroke-dasharray: var(--#{$prefix}loading-dasharray);
stroke-width: 6;
transform-origin: center;
animation: var(--#{$prefix}loading-animation);
}
}
&:has(.loading-indeterminate) {
--#{$prefix}loading-dasharray: 96;
--#{$prefix}loading-animation: 2.1875s infinite linear rotate1-indeterminate, 1.25s linear infinite rotate2-indeterminate;
}
&:has(.loading-determinate) {
--#{$prefix}loading-dasharray: 107;
--#{$prefix}loading-animation: var(--#{$prefix}loading-time) infinite linear rotate-determinate;
}
&:has(.loading-indeterminate, .loading-determinate) {
.loader {
display: block;
}
&::after {
display: none;
}
}
~ .link {
@extend %text-input-message;
}
}
.select-input-container:has(:user-invalid, [aria-invalid="true"]) {
color: $ouds-color-action-negative-enabled;
&::before {
position: absolute;
top: 50%;
right: calc(var(--#{$prefix}text-input-trailing-action-width) + var(--#{$prefix}text-input-trailing-action-padding-right) + var(--#{$prefix}text-input-column-gap-trailing-error));
z-index: 5;
display: block;
width: px-to-rem($ouds-button-size-icon-only);
height: px-to-rem($ouds-button-size-icon-only);
pointer-events: none;
content: "";
background-color: currentcolor;
mask: var(--#{$prefix}error-icon) no-repeat 50% / px-to-rem($ouds-button-size-icon-only);
transform: translate(0, -50%);
}
&:has(:hover) {
color: $ouds-color-action-negative-hover;
}
&:has(:focus-visible) {
color: $ouds-color-action-negative-focus;
}
// Forgive Safari's selectors list
&:is(:has(:open), :has(:active)) {
color: $ouds-color-action-negative-pressed;
}
> label {
max-width: calc(100% - var(--#{$prefix}text-input-trailing-action-padding-right) - var(--#{$prefix}text-input-padding-x) - var(--#{$prefix}text-input-trailing-action-width) - var(--#{$prefix}text-input-column-gap) - px-to-rem($ouds-button-size-icon-only) - var(--#{$prefix}text-input-column-gap-trailing-error));
}
~ .helper-text {
display: none;
}
~ .error-text {
display: block;
}
}
.select-input-container-outlined .select-input-field {
--#{$prefix}text-input-background-color: transparent;
--#{$prefix}text-input-border-width-top: #{$ouds-text-input-border-width-default};
--#{$prefix}text-input-border-width-right: #{$ouds-text-input-border-width-default};
--#{$prefix}text-input-border-width-left: #{$ouds-text-input-border-width-default};
// Forgive Safari's selectors list
&:is(:focus-visible, :active, :open) {
--#{$prefix}text-input-border-width-top: #{$ouds-text-input-border-width-focus};
--#{$prefix}text-input-border-width-right: #{$ouds-text-input-border-width-focus};
--#{$prefix}text-input-border-width-left: #{$ouds-text-input-border-width-focus};
}
// see https://github.com/Orange-OpenSource/Orange-Boosted-Bootstrap/issues/3465
@if $enable-bootstrap-compatibility {
&:is(:user-invalid, [aria-invalid="true"]) {
--#{$prefix}text-input-background-color: transparent;
}
}
}
option:disabled[value=""] { // stylelint-disable-line selector-no-qualifying-type
display: none;
}
option,
optgroup {
color: var(--#{$prefix}color-content-default);
background-color: var(--#{$prefix}color-bg-primary);
}
@if $enable-bootstrap-compatibility {
.form-select {
@extend .select-input;
@extend .select-input-container;
@extend .select-input-field;
appearance: auto;
}
}