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