1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | @import '../../globals/scss/vars';
|
13 | @import '../../globals/scss/helper-mixins';
|
14 | @import '../../globals/scss/layer';
|
15 | @import '../../globals/scss/vendor/@carbon/elements/scss/import-once/import-once';
|
16 | @import '../../globals/scss/css--reset';
|
17 | @import '../../globals/scss/css--typography';
|
18 | @import '../../globals/scss/layout';
|
19 |
|
20 | @mixin dropdown {
|
21 | .#{$prefix}--dropdown {
|
22 | @include reset;
|
23 | @include font-family;
|
24 | @include typescale('zeta');
|
25 | position: relative;
|
26 | list-style: none;
|
27 | display: block;
|
28 | background-color: $field-01;
|
29 | border: none;
|
30 | box-shadow: 0 1px 0 0 $ui-05;
|
31 | order: 1;
|
32 | width: 100%;
|
33 | height: rem(40px);
|
34 | cursor: pointer;
|
35 | color: $text-01;
|
36 |
|
37 | &:focus {
|
38 | outline: none;
|
39 | box-shadow: 0 2px 0 0 $brand-01;
|
40 | }
|
41 |
|
42 | &.#{$prefix}--dropdown--open:focus {
|
43 | outline: 1px solid transparent;
|
44 | box-shadow: none;
|
45 | }
|
46 |
|
47 | .#{$prefix}--dropdown--open .#{$prefix}--dropdown-list {
|
48 | @include layer('overlay');
|
49 | }
|
50 | }
|
51 |
|
52 | .#{$prefix}--dropdown--light {
|
53 | background-color: $field-02;
|
54 | }
|
55 |
|
56 | .#{$prefix}--dropdown--up {
|
57 | .#{$prefix}--dropdown-list {
|
58 | bottom: 2.5rem;
|
59 | }
|
60 | }
|
61 |
|
62 | .#{$prefix}--dropdown__arrow {
|
63 | fill: $brand-01;
|
64 | position: absolute;
|
65 | right: 1rem;
|
66 | top: 1.175rem;
|
67 | width: rem(10px);
|
68 | height: rem(5px);
|
69 | pointer-events: none;
|
70 | transition: transform $transition--expansion $carbon--standard-easing;
|
71 | transform-origin: 50% 45%;
|
72 | }
|
73 |
|
74 | .#{$prefix}--dropdown[data-value=''] .#{$prefix}--dropdown-text {
|
75 | color: $text-01;
|
76 | }
|
77 |
|
78 | .#{$prefix}--dropdown-text {
|
79 | height: rem(40px);
|
80 | padding-top: rem(13px);
|
81 | padding-bottom: rem(13px);
|
82 | padding-left: $spacing-md;
|
83 | padding-right: $spacing-2xl;
|
84 | font-weight: 600;
|
85 | white-space: nowrap;
|
86 | overflow: hidden;
|
87 | text-overflow: ellipsis;
|
88 | border: $input-border;
|
89 | }
|
90 |
|
91 | .#{$prefix}--dropdown-list {
|
92 | @include reset;
|
93 | @include layer('overlay');
|
94 | @include typescale('zeta');
|
95 | background-color: $ui-01;
|
96 | display: flex;
|
97 | flex-direction: column;
|
98 | width: 100%;
|
99 | list-style: none;
|
100 | position: absolute;
|
101 | z-index: z('dropdown');
|
102 | max-height: 0;
|
103 | transition: max-height $transition--expansion $carbon--ease-out;
|
104 | overflow: hidden;
|
105 | }
|
106 |
|
107 | .#{$prefix}--dropdown-item {
|
108 | transition: opacity $transition--expansion $carbon--ease-out;
|
109 | opacity: 0;
|
110 | }
|
111 |
|
112 | .#{$prefix}--dropdown-link {
|
113 | display: block;
|
114 | color: currentColor;
|
115 | text-decoration: none;
|
116 | font-weight: normal;
|
117 | padding: $spacing-md $spacing-lg $spacing-md $spacing-md;
|
118 | text-overflow: ellipsis;
|
119 | overflow: hidden;
|
120 |
|
121 | &:hover,
|
122 | &:focus {
|
123 | background-color: $hover-row;
|
124 | outline: 1px solid transparent;
|
125 | text-decoration: underline;
|
126 | color: $text-01;
|
127 | }
|
128 | }
|
129 |
|
130 | .#{$prefix}--dropdown--selected {
|
131 | display: none;
|
132 | }
|
133 |
|
134 | .#{$prefix}--dropdown--open {
|
135 | .#{$prefix}--dropdown__arrow {
|
136 | transform: rotate(-180deg);
|
137 | }
|
138 |
|
139 | .#{$prefix}--dropdown-list {
|
140 | max-height: 15rem;
|
141 |
|
142 | &:hover {
|
143 | overflow: auto;
|
144 | }
|
145 | }
|
146 |
|
147 | .#{$prefix}--dropdown-item {
|
148 | opacity: 1;
|
149 | }
|
150 | }
|
151 |
|
152 | .#{$prefix}--dropdown--disabled {
|
153 | opacity: 0.5;
|
154 | cursor: not-allowed;
|
155 |
|
156 | &:focus {
|
157 | outline: none;
|
158 | }
|
159 | }
|
160 |
|
161 | .#{$prefix}--dropdown--auto-width {
|
162 | width: auto;
|
163 | max-width: rem(400px);
|
164 | }
|
165 |
|
166 | .#{$prefix}--dropdown--inline {
|
167 | background-color: transparent;
|
168 | box-shadow: none;
|
169 |
|
170 | &:focus {
|
171 | outline: none;
|
172 | box-shadow: none;
|
173 | }
|
174 |
|
175 | &:focus .#{$prefix}--dropdown-text {
|
176 | @include focus-outline('border');
|
177 | }
|
178 |
|
179 | &[data-value=''] .#{$prefix}--dropdown-text {
|
180 | color: $brand-01;
|
181 | }
|
182 |
|
183 | .#{$prefix}--dropdown-text {
|
184 | display: inline-block;
|
185 | padding-right: 1.5rem;
|
186 | overflow: visible;
|
187 | color: $brand-01;
|
188 | }
|
189 |
|
190 | .#{$prefix}--dropdown-text:hover {
|
191 | background-color: $field-01;
|
192 | }
|
193 |
|
194 | &.#{$prefix}--dropdown--open:focus {
|
195 | box-shadow: none;
|
196 | }
|
197 |
|
198 | &.#{$prefix}--dropdown--open:focus .#{$prefix}--dropdown-list {
|
199 | @include layer('overlay');
|
200 | }
|
201 |
|
202 | &.#{$prefix}--dropdown--open:focus .#{$prefix}--dropdown-text {
|
203 | outline: none;
|
204 | }
|
205 |
|
206 | .#{$prefix}--dropdown__arrow {
|
207 | position: relative;
|
208 | top: -2px;
|
209 | left: 8px;
|
210 | right: 0;
|
211 | bottom: 0;
|
212 | }
|
213 |
|
214 | .#{$prefix}--dropdown-link {
|
215 | font-weight: normal;
|
216 | }
|
217 |
|
218 | .#{$prefix}--dropdown-link:hover {
|
219 | background-color: $field-01;
|
220 | color: $text-01;
|
221 | }
|
222 | }
|
223 |
|
224 |
|
225 | .#{$prefix}--dropdown-v2.#{$prefix}--skeleton,
|
226 | .#{$prefix}--dropdown.#{$prefix}--skeleton {
|
227 | @include skeleton;
|
228 | }
|
229 | }
|
230 |
|
231 | @mixin dropdown--x {
|
232 | .#{$prefix}--dropdown__wrapper--inline {
|
233 | display: inline-grid;
|
234 | align-items: center;
|
235 | grid-template: auto auto / auto min-content;
|
236 | grid-gap: rem(4px);
|
237 |
|
238 | .#{$prefix}--label {
|
239 | @include type-style('body-short-01');
|
240 | }
|
241 |
|
242 | .#{$prefix}--label,
|
243 | .#{$prefix}--form__helper-text,
|
244 | .#{$prefix}--form-requirement {
|
245 | margin: 0;
|
246 | }
|
247 |
|
248 | .#{$prefix}--form-requirement {
|
249 | grid-column: 2;
|
250 | }
|
251 | }
|
252 |
|
253 | .#{$prefix}--dropdown {
|
254 | @include reset;
|
255 | @include focus-outline('reset');
|
256 | position: relative;
|
257 | list-style: none;
|
258 | display: block;
|
259 | background-color: $field-01;
|
260 | border: none;
|
261 | border-bottom: 1px solid $ui-04;
|
262 | width: 100%;
|
263 | height: rem(40px);
|
264 | cursor: pointer;
|
265 | color: $text-01;
|
266 | outline: 2px solid transparent;
|
267 | transition: $duration--fast-02 motion(standard, productive) all;
|
268 |
|
269 | &:focus {
|
270 | @include focus-outline('outline');
|
271 | }
|
272 |
|
273 | &:hover {
|
274 | background-color: $hover-ui;
|
275 | }
|
276 | }
|
277 |
|
278 | .#{$prefix}--dropdown--open {
|
279 | border-bottom-color: $ui-03;
|
280 | }
|
281 |
|
282 | .#{$prefix}--dropdown--invalid {
|
283 | @include focus-outline('invalid');
|
284 |
|
285 | .#{$prefix}--dropdown-text {
|
286 | padding-right: rem(56px);
|
287 | }
|
288 |
|
289 | + .#{$prefix}--form-requirement {
|
290 | display: inline-block;
|
291 | max-height: rem(200px);
|
292 | color: $support-01;
|
293 | }
|
294 | }
|
295 |
|
296 | .#{$prefix}--dropdown__invalid-icon {
|
297 | position: absolute;
|
298 | top: 50%;
|
299 | right: rem(40px);
|
300 | fill: $support-01;
|
301 | transform: translateY(-50%);
|
302 | }
|
303 |
|
304 | .#{$prefix}--dropdown--open:hover {
|
305 | background-color: $field-01;
|
306 | }
|
307 |
|
308 | .#{$prefix}--dropdown--open:focus {
|
309 | outline: 1px solid transparent;
|
310 | }
|
311 |
|
312 | .#{$prefix}--dropdown--open .#{$prefix}--dropdown-list {
|
313 | @include layer('overlay');
|
314 | }
|
315 |
|
316 | .#{$prefix}--dropdown--light {
|
317 | background-color: $field-02;
|
318 | }
|
319 |
|
320 | .#{$prefix}--dropdown--up .#{$prefix}--dropdown-list {
|
321 | bottom: 2rem;
|
322 | }
|
323 |
|
324 | .#{$prefix}--dropdown__arrow {
|
325 | fill: $ui-05;
|
326 | position: absolute;
|
327 | right: 1rem;
|
328 | top: rem(13px);
|
329 | pointer-events: none;
|
330 | transition: transform $duration--fast-02 motion(standard, productive);
|
331 | transform-origin: 50% 45%;
|
332 | }
|
333 |
|
334 | .#{$prefix}--dropdown-text {
|
335 | @include type-style('body-short-01');
|
336 | display: block;
|
337 | height: rem(40px);
|
338 | padding-top: $carbon--spacing-04;
|
339 | padding-bottom: $carbon--spacing-04;
|
340 | padding-left: $carbon--spacing-05;
|
341 | padding-right: rem(42px);
|
342 | white-space: nowrap;
|
343 | overflow: hidden;
|
344 | text-overflow: ellipsis;
|
345 | }
|
346 |
|
347 | .#{$prefix}--dropdown-list {
|
348 | @include reset;
|
349 | @include layer('overlay');
|
350 | @include type-style('body-short-01');
|
351 | background-color: $ui-01;
|
352 | display: flex;
|
353 | flex-direction: column;
|
354 | width: 100%;
|
355 | list-style: none;
|
356 | position: absolute;
|
357 | z-index: z('dropdown');
|
358 | max-height: 0;
|
359 | transition: max-height $duration--fast-02 motion(standard, productive);
|
360 | overflow: hidden;
|
361 | }
|
362 |
|
363 | .#{$prefix}--dropdown-item {
|
364 | transition: opacity $duration--fast-02 motion(standard, productive),
|
365 | background-color $duration--fast-02 motion(standard, productive);
|
366 | opacity: 0;
|
367 |
|
368 | &:hover {
|
369 | background-color: $hover-ui;
|
370 |
|
371 | + .#{$prefix}--dropdown-item .#{$prefix}--dropdown-link {
|
372 | border-color: transparent;
|
373 | }
|
374 | }
|
375 |
|
376 | &:active {
|
377 | background-color: $selected-ui;
|
378 | }
|
379 |
|
380 | &:first-of-type .#{$prefix}--dropdown-link {
|
381 | border-top-color: transparent;
|
382 | }
|
383 | }
|
384 |
|
385 | .#{$prefix}--dropdown-item:last-of-type .#{$prefix}--dropdown-link {
|
386 | border-bottom: none;
|
387 | }
|
388 |
|
389 | .#{$prefix}--dropdown-link {
|
390 | @include focus-outline('reset');
|
391 | display: block;
|
392 | height: rem(40px);
|
393 | color: $text-02;
|
394 | text-decoration: none;
|
395 | font-weight: normal;
|
396 | line-height: rem(16px);
|
397 | padding: rem(11px) 0;
|
398 | margin: 0 $carbon--spacing-05;
|
399 | border: 1px solid transparent;
|
400 | border-top-color: $ui-03;
|
401 | text-overflow: ellipsis;
|
402 | overflow: hidden;
|
403 | white-space: nowrap;
|
404 |
|
405 | &:focus {
|
406 | @include focus-outline('outline');
|
407 | margin: 0;
|
408 | padding: rem(11px) rem(16px);
|
409 | }
|
410 |
|
411 | &:hover {
|
412 | color: $text-01;
|
413 | border-color: transparent;
|
414 | }
|
415 | }
|
416 |
|
417 | .#{$prefix}--dropdown-item:hover .#{$prefix}--dropdown-link {
|
418 | border-bottom-color: $hover-ui;
|
419 | }
|
420 |
|
421 | .#{$prefix}--dropdown--selected {
|
422 | display: none;
|
423 | }
|
424 |
|
425 | .#{$prefix}--dropdown--open .#{$prefix}--dropdown__arrow {
|
426 | transform: rotate(-180deg);
|
427 | }
|
428 |
|
429 | .#{$prefix}--dropdown--open .#{$prefix}--dropdown-list {
|
430 | max-height: 15rem;
|
431 |
|
432 | &:hover {
|
433 | overflow: auto;
|
434 | }
|
435 | }
|
436 |
|
437 | .#{$prefix}--dropdown--open .#{$prefix}--dropdown-item {
|
438 | opacity: 1;
|
439 | }
|
440 |
|
441 | .#{$prefix}--dropdown--disabled {
|
442 | border-bottom-color: transparent;
|
443 | cursor: not-allowed;
|
444 |
|
445 | &:hover {
|
446 | background-color: $field-01;
|
447 | }
|
448 |
|
449 | &:focus {
|
450 | outline: none;
|
451 | }
|
452 |
|
453 | .#{$prefix}--dropdown-text {
|
454 | color: $disabled-02;
|
455 | }
|
456 |
|
457 | .#{$prefix}--dropdown__arrow {
|
458 | fill: $disabled-02;
|
459 | }
|
460 |
|
461 | &.#{$prefix}--dropdown--light:hover {
|
462 | background-color: $field-02;
|
463 | }
|
464 | }
|
465 |
|
466 | .#{$prefix}--dropdown--auto-width {
|
467 | width: auto;
|
468 | max-width: rem(400px);
|
469 | }
|
470 |
|
471 | .#{$prefix}--dropdown--inline {
|
472 | justify-self: start;
|
473 | display: inline-block;
|
474 | border-bottom-color: transparent;
|
475 | transition-property: none;
|
476 | width: auto;
|
477 | height: rem(32px);
|
478 | background-color: $field-02;
|
479 |
|
480 | &:hover {
|
481 | background-color: $hover-ui;
|
482 | }
|
483 |
|
484 | &.#{$prefix}--dropdown--disabled {
|
485 | background-color: $field-02;
|
486 | }
|
487 |
|
488 | .#{$prefix}--dropdown__arrow {
|
489 | top: rem(8px);
|
490 | right: rem(8px);
|
491 | }
|
492 | }
|
493 |
|
494 | .#{$prefix}--dropdown--inline.#{$prefix}--dropdown--open {
|
495 | background-color: transparent;
|
496 | }
|
497 |
|
498 | .#{$prefix}--dropdown--inline .#{$prefix}--dropdown-text {
|
499 | display: inline-block;
|
500 | padding: rem(7px) rem(32px) rem(7px) $carbon--spacing-04;
|
501 | height: rem(32px);
|
502 | overflow: visible;
|
503 | color: $text-01;
|
504 | }
|
505 |
|
506 | .#{$prefix}--dropdown--inline.#{$prefix}--dropdown--disabled .#{$prefix}--dropdown-text {
|
507 | color: $disabled-02;
|
508 | }
|
509 |
|
510 | .#{$prefix}--dropdown--inline.#{$prefix}--dropdown--disabled:focus .#{$prefix}--dropdown-text {
|
511 | outline: 0;
|
512 | }
|
513 |
|
514 | .#{$prefix}--dropdown--inline.#{$prefix}--dropdown--invalid .#{$prefix}--dropdown__invalid-icon {
|
515 | right: rem(32px);
|
516 | }
|
517 |
|
518 | .#{$prefix}--dropdown--inline.#{$prefix}--dropdown--invalid .#{$prefix}--dropdown-text {
|
519 | padding-right: rem(56px);
|
520 | }
|
521 |
|
522 | .#{$prefix}--dropdown--inline.#{$prefix}--dropdown--open:focus .#{$prefix}--dropdown-list {
|
523 | @include layer('overlay');
|
524 | }
|
525 |
|
526 | .#{$prefix}--dropdown--inline .#{$prefix}--dropdown-link {
|
527 | font-weight: normal;
|
528 | margin-right: $carbon--spacing-04;
|
529 | margin-left: rem(10px);
|
530 |
|
531 | &:focus {
|
532 | margin: 0;
|
533 | padding-left: rem(10px);
|
534 | }
|
535 | }
|
536 |
|
537 |
|
538 | .#{$prefix}--dropdown-v2.#{$prefix}--skeleton,
|
539 | .#{$prefix}--dropdown.#{$prefix}--skeleton {
|
540 | @include skeleton;
|
541 | }
|
542 | }
|
543 |
|
544 | @include exports('dropdown') {
|
545 | @if feature-flag-enabled('components-x') {
|
546 | @include dropdown--x;
|
547 | } @else {
|
548 | @include dropdown;
|
549 | }
|
550 | }
|