|
52 | 52 | }
|
53 | 53 |
|
54 | 54 | .mat-input-underline {
|
55 |
| - border-color: $input-underline-color; |
| 55 | + background-color: $input-underline-color; |
56 | 56 | }
|
57 | 57 |
|
58 | 58 | .mat-input-ripple {
|
|
91 | 91 | }
|
92 | 92 |
|
93 | 93 | @mixin mat-input-typography($config) {
|
| 94 | + // The unit-less line-height from the font config. |
| 95 | + $mat-input-line-height: mat-line-height($config, input); |
| 96 | + |
| 97 | + // The amount to scale the font for the floating label and subscript. |
| 98 | + $mat-input-subscript-font-scale: 0.75; |
| 99 | + // The amount to scale the font for the prefix and suffix icons. |
| 100 | + $mat-input-prefix-suffix-icon-font-scale: 1.5; |
| 101 | + |
| 102 | + // The amount of space between the top of the line and the top of the actual text |
| 103 | + // (as a fraction of the font-size). |
| 104 | + $mat-input-line-spacing: ($mat-input-line-height - 1) / 2; |
| 105 | + // The padding on the infix. Mocks show half of the text size, but seem to measure from the edge |
| 106 | + // of the text itself, not the edge of the line; therefore we subtract off the line spacing. |
| 107 | + $mat-input-infix-padding: 0.5em - $mat-input-line-spacing; |
| 108 | + // The margin applied to the input-infix to reserve space for the floating label. |
| 109 | + $mat-input-infix-margin-top: 1em * $mat-input-line-height * $mat-input-subscript-font-scale; |
| 110 | + // Font size to use for the label and subscript text. |
| 111 | + $mat-input-subscript-font-size: $mat-input-subscript-font-scale * 100%; |
| 112 | + // Font size to use for the for the prefix and suffix icons. |
| 113 | + $mat-input-prefix-suffix-icon-font-size: $mat-input-prefix-suffix-icon-font-scale * 100%; |
| 114 | + // The space between the bottom of the input table and the subscript container. Mocks show half of |
| 115 | + // the text size, but this margin is applied to an element with the subscript text font size, so |
| 116 | + // we need to divide by the scale factor to make it half of the original text size. We again need |
| 117 | + // to subtract off the line spacing since the mocks measure to the edge of the text, not the edge |
| 118 | + // of the line. |
| 119 | + $mat-input-subscript-margin-top: |
| 120 | + 0.5em / $mat-input-subscript-font-scale - $mat-input-line-spacing; |
| 121 | + // The padding applied to the input-wrapper to reserve space for the subscript, since it's |
| 122 | + // absolutely positioned. This is a combination of the subscript's margin and line-height, but we |
| 123 | + // need to multiply by the subscript font scale factor since the wrapper has a larger font size. |
| 124 | + $mat-input-wrapper-padding-bottom: |
| 125 | + ($mat-input-subscript-margin-top + $mat-input-line-height) * $mat-input-subscript-font-scale; |
| 126 | + |
| 127 | + // Applies a floating placeholder above the input itself. |
| 128 | + @mixin mat-input-placeholder-floating { |
| 129 | + transform: translateY(-$mat-input-infix-margin-top - $mat-input-infix-padding) |
| 130 | + scale($mat-input-subscript-font-scale) |
| 131 | + // We use perspecitve to fix the text blurriness as described here: |
| 132 | + // http://www.useragentman.com/blog/2014/05/04/fixing-typography-inside-of-2-d-css-transforms/ |
| 133 | + // This results in a small jitter after the label floats on Firefox, which the |
| 134 | + // translateZ fixes. |
| 135 | + perspective(100px) translateZ(0.001px); |
| 136 | + // The tricks above used to smooth out the animation on chrome and firefox actually make things |
| 137 | + // worse on IE, so we don't include them in the IE version. |
| 138 | + -ms-transform: translateY(-$mat-input-infix-margin-top - $mat-input-infix-padding) |
| 139 | + scale($mat-input-subscript-font-scale); |
| 140 | + |
| 141 | + width: 100% / $mat-input-subscript-font-scale; |
| 142 | + } |
| 143 | + |
94 | 144 | .mat-input-container {
|
95 |
| - font-family: mat-font-family($config); |
96 |
| - line-height: normal; |
| 145 | + @include mat-typography-level-to-styles($config, input); |
| 146 | + } |
| 147 | + |
| 148 | + .mat-input-wrapper { |
| 149 | + padding-bottom: $mat-input-wrapper-padding-bottom; |
| 150 | + } |
| 151 | + |
| 152 | + .mat-input-prefix, |
| 153 | + .mat-input-suffix { |
| 154 | + // Allow icons in a prefix or suffix to adapt to the correct size. |
| 155 | + .mat-icon, |
| 156 | + .mat-datepicker-toggle { |
| 157 | + font-size: $mat-input-prefix-suffix-icon-font-size; |
| 158 | + } |
| 159 | + |
| 160 | + // Allow icon buttons in a prefix or suffix to adapt to the correct size. |
| 161 | + .mat-icon-button { |
| 162 | + height: $mat-input-prefix-suffix-icon-font-scale * 1em; |
| 163 | + width: $mat-input-prefix-suffix-icon-font-scale * 1em; |
| 164 | + |
| 165 | + .mat-icon { |
| 166 | + line-height: $mat-input-prefix-suffix-icon-font-scale; |
| 167 | + } |
| 168 | + } |
| 169 | + } |
| 170 | + |
| 171 | + .mat-input-infix { |
| 172 | + padding: $mat-input-infix-padding 0; |
| 173 | + // Throws off the baseline if we do it as a real margin, so we do it as a border instead. |
| 174 | + border-top: $mat-input-infix-margin-top solid transparent; |
| 175 | + } |
97 | 176 |
|
98 |
| - .mat-icon { |
99 |
| - font-size: 100%; |
| 177 | + .mat-input-element { |
| 178 | + &:-webkit-autofill + .mat-input-placeholder-wrapper .mat-float { |
| 179 | + @include mat-input-placeholder-floating; |
100 | 180 | }
|
101 | 181 | }
|
102 | 182 |
|
| 183 | + .mat-input-placeholder-wrapper { |
| 184 | + top: -$mat-input-infix-margin-top; |
| 185 | + padding-top: $mat-input-infix-margin-top; |
| 186 | + } |
| 187 | + |
103 | 188 | .mat-input-placeholder {
|
104 |
| - font-size: 100%; |
| 189 | + top: $mat-input-infix-margin-top + $mat-input-infix-padding; |
| 190 | + |
| 191 | + // Show the placeholder above the input when it's not empty, or focused. |
| 192 | + &.mat-float:not(.mat-empty), .mat-focused &.mat-float { |
| 193 | + @include mat-input-placeholder-floating; |
| 194 | + } |
| 195 | + } |
| 196 | + |
| 197 | + .mat-input-underline { |
| 198 | + // We want the underline to start at the end of the content box, not the padding box, |
| 199 | + // so we move it up by the padding amount; |
| 200 | + bottom: $mat-input-wrapper-padding-bottom; |
105 | 201 | }
|
106 | 202 |
|
107 | 203 | .mat-input-subscript-wrapper {
|
108 |
| - font-size: 75%; |
| 204 | + font-size: $mat-input-subscript-font-size; |
| 205 | + margin-top: $mat-input-subscript-margin-top; |
| 206 | + |
| 207 | + // We want the subscript to start at the end of the content box, not the padding box, |
| 208 | + // so we move it up by the padding amount (adjusted for the smaller font size); |
| 209 | + top: calc(100% - #{$mat-input-wrapper-padding-bottom / $mat-input-subscript-font-scale}); |
109 | 210 | }
|
110 | 211 | }
|
0 commit comments