|
95 | 95 | .mdc-text-field__input { |
96 | 96 | // Exclude setting line-height to keep caret (text cursor) same height as the input text in iOS browser. |
97 | 97 | @include typography-mixins.typography(subtitle1, $exclude-props: (line-height), $query: $query); |
| 98 | + @include input-padding_($query: $query); |
98 | 99 |
|
99 | 100 | @include feature-targeting-mixins.targets($feat-structure) { |
100 | 101 | align-self: flex-end; |
101 | 102 | box-sizing: border-box; |
102 | 103 | width: 100%; |
103 | 104 | height: 100%; |
104 | | - padding: |
105 | | - variables.$input-padding-top |
106 | | - variables.$input-padding |
107 | | - variables.$input-padding-bottom + variables.$input-border-bottom; |
108 | 105 | border: none; |
109 | 106 | border-radius: 0; |
110 | 107 | background: none; |
|
162 | 159 |
|
163 | 160 | // Vertically center aligns the text input placeholder and value for only filled variant. |
164 | 161 | .mdc-text-field--no-label:not(.mdc-text-field--outlined):not(.mdc-text-field--textarea) & { |
165 | | - @include feature-targeting-mixins.targets($feat-structure) { |
166 | | - padding-top: 16px; |
167 | | - padding-bottom: 16px + variables.$input-border-bottom; |
168 | | - } |
| 162 | + @include input-no-label-padding_($query: $query); |
169 | 163 | } |
170 | 164 | } |
171 | 165 |
|
|
389 | 383 | /// |
390 | 384 | /// @param {Number | String} $density-scale - Density scale value for component. Supported density scale values `-4`, |
391 | 385 | /// `-3`, `-2`, `-1`, `0`. Default is `0`. |
| 386 | +/// @param {Number} $minimum-height-for-filled-label Sets the minimum height for |
| 387 | +/// filled textfields at which to allow floating labels. |
392 | 388 | /// |
393 | | -@mixin density($density-scale, $query: feature-targeting-functions.all()) { |
| 389 | +@mixin density($density-scale, $minimum-height-for-filled-label: variables.$minimum-height-for-filled-label, $query: feature-targeting-functions.all()) { |
394 | 390 | $height: density-functions.prop-value( |
395 | 391 | $density-config: variables.$density-config, |
396 | 392 | $density-scale: $density-scale, |
397 | 393 | $property-name: height, |
398 | 394 | ); |
399 | 395 |
|
400 | | - @include height($height, $query: $query); |
| 396 | + @include height($height, $minimum-height-for-filled-label: $minimum-height-for-filled-label, $query: $query); |
401 | 397 | } |
402 | 398 |
|
403 | 399 | /// |
|
436 | 432 | /// Sets height of default text field variant. |
437 | 433 | /// |
438 | 434 | /// @param {Number} $height |
| 435 | +/// @param {Number} $minimum-height-for-filled-label Sets the minimum height for |
| 436 | +/// filled textfields at which to allow floating labels. |
439 | 437 | /// @access public |
440 | 438 | /// |
441 | | -@mixin height($height, $query: feature-targeting-functions.all()) { |
| 439 | +@mixin height($height, $minimum-height-for-filled-label: variables.$minimum-height-for-filled-label, $query: feature-targeting-functions.all()) { |
442 | 440 | $feat-structure: feature-targeting-functions.create-target($query, structure); |
443 | 441 |
|
444 | 442 | @include feature-targeting-mixins.targets($feat-structure) { |
445 | 443 | height: $height; |
446 | 444 | } |
447 | 445 |
|
448 | | - // Target only dense text field. |
449 | | - @if $height <= 40px { |
450 | | - // Target only IE 11. |
451 | | - @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) { |
452 | | - .mdc-text-field__input { |
453 | | - @include feature-targeting-mixins.targets($feat-structure) { |
454 | | - // Set line-height to the height of input element excluding padding & border. |
455 | | - line-height: |
456 | | - $height |
457 | | - - variables.$input-padding-top |
458 | | - - variables.$input-padding-bottom |
459 | | - - variables.$input-border-bottom; |
| 446 | + @if $height < $minimum-height-for-filled-label { |
| 447 | + // Filled text fields must be tall enough to display a label |
| 448 | + &:not(.mdc-text-field--outlined):not(.mdc-text-field--textarea) { |
| 449 | + @include feature-targeting-mixins.targets($feat-structure) { |
| 450 | + .mdc-floating-label { |
| 451 | + display: none; |
460 | 452 | } |
461 | 453 | } |
| 454 | + |
| 455 | + .mdc-text-field__input { |
| 456 | + @include input-no-label-padding_($query: $query); |
| 457 | + } |
462 | 458 | } |
463 | 459 | } |
464 | 460 | } |
|
741 | 737 |
|
742 | 738 | // Baseline |
743 | 739 |
|
| 740 | +@mixin input-padding_($query: feature-targeting-functions.all()) { |
| 741 | + $feat-structure: feature-targeting-functions.create-target($query, structure); |
| 742 | + |
| 743 | + @include feature-targeting-mixins.targets($feat-structure) { |
| 744 | + padding: |
| 745 | + variables.$input-padding-top |
| 746 | + variables.$input-padding |
| 747 | + variables.$input-padding-bottom + variables.$input-border-bottom; |
| 748 | + } |
| 749 | +} |
| 750 | + |
| 751 | +@mixin input-no-label-padding_($query: feature-targeting-functions.all()) { |
| 752 | + $feat-structure: feature-targeting-functions.create-target($query, structure); |
| 753 | + |
| 754 | + @include feature-targeting-mixins.targets($feat-structure) { |
| 755 | + padding-top: 0; |
| 756 | + padding-bottom: variables.$input-border-bottom; |
| 757 | + } |
| 758 | +} |
| 759 | + |
744 | 760 | @mixin disabled_($query: feature-targeting-functions.all()) { |
745 | 761 | $feat-structure: feature-targeting-functions.create-target($query, structure); |
746 | 762 |
|
|
1016 | 1032 | } |
1017 | 1033 |
|
1018 | 1034 | .mdc-text-field__input { |
| 1035 | + @include outlined-input-padding_($query: $query); |
1019 | 1036 | @include feature-targeting-mixins.targets($feat-structure) { |
1020 | 1037 | display: flex; |
1021 | | - padding: 12px 16px 14px; |
1022 | 1038 | border: none !important; // FF adds unwanted border in HC mode on windows. |
1023 | 1039 | background-color: transparent; |
1024 | 1040 | z-index: 1; |
|
1036 | 1052 | } |
1037 | 1053 | } |
1038 | 1054 |
|
| 1055 | +@mixin outlined-input-padding_($query: feature-targeting-functions.all()) { |
| 1056 | + $feat-structure: feature-targeting-functions.create-target($query, structure); |
| 1057 | + |
| 1058 | + @include feature-targeting-mixins.targets($feat-structure) { |
| 1059 | + padding-top: variables.$outlined-input-padding-top; |
| 1060 | + padding-bottom: variables.$outlined-input-padding-bottom; |
| 1061 | + } |
| 1062 | +} |
| 1063 | + |
1039 | 1064 | @mixin hover-outline-color_($color, $query: feature-targeting-functions.all()) { |
1040 | 1065 | &:not(.mdc-text-field--focused):hover { |
1041 | 1066 | .mdc-notched-outline { |
|
0 commit comments