|
392 | 392 | // Input Label
|
393 | 393 | // ----------------------------------------------------------------
|
394 | 394 |
|
395 |
| -.input-wrapper label { |
| 395 | +.label-text-wrapper { |
396 | 396 | /**
|
397 | 397 | * The margin between the label and
|
398 | 398 | * the input should be on the end
|
|
410 | 410 | align-items: center;
|
411 | 411 |
|
412 | 412 | transition: color 150ms cubic-bezier(.4, 0, .2, 1), transform 150ms cubic-bezier(.4, 0, .2, 1);
|
| 413 | + |
| 414 | + /** |
| 415 | + * This ensures that double tapping this text |
| 416 | + * clicks the <label> and focuses the input |
| 417 | + * when a screen reader is enabled. |
| 418 | + */ |
| 419 | + pointer-events: none; |
| 420 | +} |
| 421 | + |
| 422 | +/** |
| 423 | + * We need to use two elements instead of |
| 424 | + * one. The .label-text-wrapper is responsible |
| 425 | + * for centering the label text vertically regardless |
| 426 | + * of the input height using flexbox. |
| 427 | + * |
| 428 | + * The .label-text element is responsible for controlling |
| 429 | + * overflow when label-placement="fixed". |
| 430 | + * We want the ellipses to show up when the |
| 431 | + * fixed label overflows, but text-overflow: ellipsis only |
| 432 | + * works on block-level elements. A flex item is |
| 433 | + * considered blockified (https://www.w3.org/TR/css-display-3/#blockify). |
| 434 | + */ |
| 435 | +.label-text { |
| 436 | + text-overflow: ellipsis; |
| 437 | + |
| 438 | + white-space: nowrap; |
| 439 | + |
| 440 | + overflow: hidden; |
413 | 441 | }
|
414 | 442 |
|
415 | 443 | .input-wrapper input {
|
|
448 | 476 | * the input should be on the start
|
449 | 477 | * when the label sits at the end.
|
450 | 478 | */
|
451 |
| -:host(.input-label-placement-end) label { |
| 479 | +:host(.input-label-placement-end) .label-text-wrapper { |
452 | 480 | @include margin(0, 0, 0, 8px);
|
453 | 481 | }
|
454 | 482 |
|
|
459 | 487 | * Label is on the left of the input in LTR and
|
460 | 488 | * on the right in RTL. Label also has a fixed width.
|
461 | 489 | */
|
462 |
| -:host(.input-label-placement-fixed) label { |
463 |
| - @include margin(0, 0, 0, 0); |
464 |
| - |
| 490 | +:host(.input-label-placement-fixed) .label-text { |
465 | 491 | flex: 0 0 100px;
|
466 | 492 |
|
467 | 493 | width: 100px;
|
|
490 | 516 | * up and to the left in LTR or
|
491 | 517 | * up and to the right in RTL.
|
492 | 518 | */
|
493 |
| -:host(.input-label-placement-stacked) label, |
494 |
| -:host(.input-label-placement-floating) label { |
| 519 | +:host(.input-label-placement-stacked) .label-text-wrapper, |
| 520 | +:host(.input-label-placement-floating) .label-text-wrapper { |
495 | 521 | @include transform-origin(start, top);
|
496 | 522 | }
|
497 | 523 |
|
|
508 | 534 | * This makes the label sit over the input
|
509 | 535 | * when the input is blurred and has no value.
|
510 | 536 | */
|
511 |
| -:host(.input-label-placement-floating) label { |
| 537 | +:host(.input-label-placement-floating) .label-text-wrapper { |
512 | 538 | @include transform(translateY(100%), scale(1));
|
513 | 539 | }
|
514 | 540 |
|
|
529 | 555 | /**
|
530 | 556 | * This makes the label sit above the input.
|
531 | 557 | */
|
532 |
| -:host(.input-label-placement-stacked) label, |
533 |
| -:host(.has-focus.input-label-placement-floating) label, |
534 |
| -:host(.has-value.input-label-placement-floating) label { |
| 558 | +:host(.input-label-placement-stacked) .label-text-wrapper, |
| 559 | +:host(.has-focus.input-label-placement-floating) .label-text-wrapper, |
| 560 | +:host(.has-value.input-label-placement-floating) .label-text-wrapper { |
535 | 561 | @include transform(translateY(50%), scale(.75));
|
536 | 562 | }
|
0 commit comments