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: flex;
|
337 | align-items: center;
|
338 | height: rem(40px);
|
339 | padding-top: $carbon--spacing-04;
|
340 | padding-bottom: $carbon--spacing-04;
|
341 | padding-left: $carbon--spacing-05;
|
342 | padding-right: rem(42px);
|
343 | white-space: nowrap;
|
344 | overflow: hidden;
|
345 | text-overflow: ellipsis;
|
346 | }
|
347 |
|
348 | .#{$prefix}--dropdown-list {
|
349 | @include reset;
|
350 | @include layer('overlay');
|
351 | @include type-style('body-short-01');
|
352 | background-color: $ui-01;
|
353 | display: flex;
|
354 | flex-direction: column;
|
355 | width: 100%;
|
356 | list-style: none;
|
357 | position: absolute;
|
358 | z-index: z('dropdown');
|
359 | max-height: 0;
|
360 | transition: max-height $duration--fast-02 motion(standard, productive);
|
361 | overflow: hidden;
|
362 | }
|
363 |
|
364 | .#{$prefix}--dropdown-item {
|
365 | transition: opacity $duration--fast-02 motion(standard, productive),
|
366 | background-color $duration--fast-02 motion(standard, productive);
|
367 | opacity: 0;
|
368 |
|
369 | &:hover {
|
370 | background-color: $hover-ui;
|
371 |
|
372 | + .#{$prefix}--dropdown-item .#{$prefix}--dropdown-link {
|
373 | border-color: transparent;
|
374 | }
|
375 | }
|
376 |
|
377 | &:active {
|
378 | background-color: $selected-ui;
|
379 | }
|
380 |
|
381 | &:first-of-type .#{$prefix}--dropdown-link {
|
382 | border-top-color: transparent;
|
383 | }
|
384 | }
|
385 |
|
386 | .#{$prefix}--dropdown-item:last-of-type .#{$prefix}--dropdown-link {
|
387 | border-bottom: none;
|
388 | }
|
389 |
|
390 | .#{$prefix}--dropdown-link {
|
391 | @include focus-outline('reset');
|
392 | display: block;
|
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 rem(16px);
|
399 | border: 1px solid transparent;
|
400 | border-top-color: $ui-03;
|
401 | text-overflow: ellipsis;
|
402 | overflow: hidden;
|
403 |
|
404 | &:focus {
|
405 | @include focus-outline('outline');
|
406 | margin: 0;
|
407 | padding: rem(11px) rem(16px);
|
408 | }
|
409 |
|
410 | &:hover {
|
411 | color: $text-01;
|
412 | border-color: transparent;
|
413 | }
|
414 | }
|
415 |
|
416 | .#{$prefix}--dropdown-item:hover .#{$prefix}--dropdown-link {
|
417 | border-bottom-color: $hover-ui;
|
418 | }
|
419 |
|
420 | .#{$prefix}--dropdown--selected {
|
421 | display: none;
|
422 | }
|
423 |
|
424 | .#{$prefix}--dropdown--open .#{$prefix}--dropdown__arrow {
|
425 | transform: rotate(-180deg);
|
426 | }
|
427 |
|
428 | .#{$prefix}--dropdown--open .#{$prefix}--dropdown-list {
|
429 | max-height: 15rem;
|
430 |
|
431 | &:hover {
|
432 | overflow: auto;
|
433 | }
|
434 | }
|
435 |
|
436 | .#{$prefix}--dropdown--open .#{$prefix}--dropdown-item {
|
437 | opacity: 1;
|
438 | }
|
439 |
|
440 | .#{$prefix}--dropdown--disabled {
|
441 | border-bottom-color: transparent;
|
442 | cursor: not-allowed;
|
443 |
|
444 | &:hover {
|
445 | background-color: $field-01;
|
446 | }
|
447 |
|
448 | &:focus {
|
449 | outline: none;
|
450 | }
|
451 |
|
452 | .#{$prefix}--dropdown-text {
|
453 | color: $disabled-02;
|
454 | }
|
455 |
|
456 | .#{$prefix}--dropdown__arrow {
|
457 | fill: $disabled-02;
|
458 | }
|
459 |
|
460 | &.#{$prefix}--dropdown--light:hover {
|
461 | background-color: $field-02;
|
462 | }
|
463 | }
|
464 |
|
465 | .#{$prefix}--dropdown--auto-width {
|
466 | width: auto;
|
467 | max-width: rem(400px);
|
468 | }
|
469 |
|
470 | .#{$prefix}--dropdown--inline {
|
471 | justify-self: start;
|
472 | display: inline-block;
|
473 | border-bottom-color: transparent;
|
474 | transition-property: none;
|
475 | width: auto;
|
476 | height: rem(32px);
|
477 | background-color: $field-02;
|
478 |
|
479 | &:hover {
|
480 | background-color: $hover-ui;
|
481 | }
|
482 |
|
483 | &.#{$prefix}--dropdown--disabled {
|
484 | background-color: $field-02;
|
485 | }
|
486 |
|
487 | .#{$prefix}--dropdown__arrow {
|
488 | top: rem(8px);
|
489 | right: rem(8px);
|
490 | }
|
491 | }
|
492 |
|
493 | .#{$prefix}--dropdown--inline.#{$prefix}--dropdown--open {
|
494 | background-color: transparent;
|
495 | }
|
496 |
|
497 | .#{$prefix}--dropdown--inline .#{$prefix}--dropdown-text {
|
498 | display: inline-block;
|
499 | padding: rem(7px) rem(32px) rem(7px) $carbon--spacing-04;
|
500 | height: rem(32px);
|
501 | overflow: visible;
|
502 | color: $text-01;
|
503 | }
|
504 |
|
505 | .#{$prefix}--dropdown--inline.#{$prefix}--dropdown--disabled .#{$prefix}--dropdown-text {
|
506 | color: $disabled-02;
|
507 | }
|
508 |
|
509 | .#{$prefix}--dropdown--inline.#{$prefix}--dropdown--disabled:focus .#{$prefix}--dropdown-text {
|
510 | outline: 0;
|
511 | }
|
512 |
|
513 | .#{$prefix}--dropdown--inline.#{$prefix}--dropdown--invalid .#{$prefix}--dropdown__invalid-icon {
|
514 | right: rem(32px);
|
515 | }
|
516 |
|
517 | .#{$prefix}--dropdown--inline.#{$prefix}--dropdown--invalid .#{$prefix}--dropdown-text {
|
518 | padding-right: rem(56px);
|
519 | }
|
520 |
|
521 | .#{$prefix}--dropdown--inline.#{$prefix}--dropdown--open:focus .#{$prefix}--dropdown-list {
|
522 | @include layer('overlay');
|
523 | }
|
524 |
|
525 | .#{$prefix}--dropdown--inline .#{$prefix}--dropdown-link {
|
526 | font-weight: normal;
|
527 | margin-right: $carbon--spacing-04;
|
528 | margin-left: rem(10px);
|
529 |
|
530 | &:focus {
|
531 | margin: 0;
|
532 | padding-left: rem(10px);
|
533 | }
|
534 | }
|
535 |
|
536 |
|
537 | .#{$prefix}--dropdown-v2.#{$prefix}--skeleton,
|
538 | .#{$prefix}--dropdown.#{$prefix}--skeleton {
|
539 | @include skeleton;
|
540 | }
|
541 | }
|
542 |
|
543 | @include exports('dropdown') {
|
544 | @if feature-flag-enabled('components-x') {
|
545 | @include dropdown--x;
|
546 | } @else {
|
547 | @include dropdown;
|
548 | }
|
549 | }
|