Skip to content

Commit 37efb54

Browse files
crisbetojelbourn
authored andcommitted
fix(input): theming mixin error (#5254)
* Fixes an error in the input theming mixin that was caused by a nested mixin. * Removes the `mat-input-` prefix from the mixin local variables since they're not exposed and don't need to be prefixed. Fixes #5232.
1 parent 1dcaca7 commit 37efb54

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

src/lib/input/_input-theme.scss

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
color: mat-color($foreground, disabled-text);
4444
}
4545

46-
// See mat-input-placeholder-floating mixin in input-container.scss
46+
// See _mat-input-placeholder-floating mixin in input-container.scss
4747
input.mat-input-element:-webkit-autofill + .mat-input-placeholder,
4848
.mat-focused .mat-input-placeholder.mat-float {
4949
.mat-placeholder-required {
@@ -90,122 +90,122 @@
9090
}
9191
}
9292

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+
93110
@mixin mat-input-typography($config) {
94111
// 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);
96113

97114
// 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;
99116
// 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;
101118

102119
// The amount of space between the top of the line and the top of the actual text
103120
// (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;
105122
// The padding on the infix. Mocks show half of the text size, but seem to measure from the edge
106123
// 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;
108125
// 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;
110127
// 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%;
112129
// 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%;
114131
// The space between the bottom of the input table and the subscript container. Mocks show half of
115132
// the text size, but this margin is applied to an element with the subscript text font size, so
116133
// we need to divide by the scale factor to make it half of the original text size. We again need
117134
// to subtract off the line spacing since the mocks measure to the edge of the text, not the edge
118135
// 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;
121137
// The padding applied to the input-wrapper to reserve space for the subscript, since it's
122138
// absolutely positioned. This is a combination of the subscript's margin and line-height, but we
123139
// 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;
143141

144142
.mat-input-container {
145143
@include mat-typography-level-to-styles($config, input);
146144
}
147145

148146
.mat-input-wrapper {
149-
padding-bottom: $mat-input-wrapper-padding-bottom;
147+
padding-bottom: $wrapper-padding-bottom;
150148
}
151149

152150
.mat-input-prefix,
153151
.mat-input-suffix {
154152
// Allow icons in a prefix or suffix to adapt to the correct size.
155153
.mat-icon,
156154
.mat-datepicker-toggle {
157-
font-size: $mat-input-prefix-suffix-icon-font-size;
155+
font-size: $prefix-suffix-icon-font-size;
158156
}
159157

160158
// Allow icon buttons in a prefix or suffix to adapt to the correct size.
161159
.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;
164162

165163
.mat-icon {
166-
line-height: $mat-input-prefix-suffix-icon-font-scale;
164+
line-height: $prefix-suffix-icon-font-scale;
167165
}
168166
}
169167
}
170168

171169
.mat-input-infix {
172-
padding: $mat-input-infix-padding 0;
170+
padding: $infix-padding 0;
173171
// 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;
175173
}
176174

177175
.mat-input-element {
178176
&:-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);
180179
}
181180
}
182181

183182
.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;
186185
}
187186

188187
.mat-input-placeholder {
189-
top: $mat-input-infix-margin-top + $mat-input-infix-padding;
188+
top: $infix-margin-top + $infix-padding;
190189

191190
// Show the placeholder above the input when it's not empty, or focused.
192191
&.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);
194194
}
195195
}
196196

197197
.mat-input-underline {
198198
// 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;
201201
}
202202

203203
.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;
206206

207207
// We want the subscript to start at the end of the content box, not the padding box,
208208
// 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});
210210
}
211211
}

0 commit comments

Comments
 (0)