-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(material-experimental/mdc-typography): update mdc components typography to match spec #21676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b8cbd87
6e9dc70
8992161
e4bddef
63ac863
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,16 +8,35 @@ | |
.mat-mdc-form-field-subscript-wrapper { | ||
box-sizing: border-box; | ||
width: 100%; | ||
// prevents multi-line errors from overlapping the control. | ||
overflow: hidden; | ||
position: relative; | ||
} | ||
|
||
// The horizontal padding between the edge of the text box and the start of the subscript text. | ||
$subscript-horizontal-padding: 16px; | ||
|
||
.mat-mdc-form-field-hint-wrapper, | ||
.mat-mdc-form-field-error-wrapper { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it intentional to not include There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the idea is to behave like the non-MDC form-field where the user can add multiple error/hint or long ones that wrap, but they'll have to reserve space for it themselves. We only reserve space in the layout for one line worth of message. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should maybe talk about this- I think we should change our behavior over to what mdc does, but I know that would be pretty breaking, so we should think about doing a follow-up that lets users switch. |
||
padding: 0 $subscript-horizontal-padding; | ||
} | ||
|
||
.mat-mdc-form-field-bottom-align::before { | ||
content: ''; | ||
display: inline-block; | ||
height: 16px; | ||
} | ||
|
||
// Scale down icons in the subscript to be the same size as the text. | ||
.mat-mdc-form-field-subscript-wrapper .mat-icon { | ||
width: 1em; | ||
height: 1em; | ||
font-size: inherit; | ||
vertical-align: baseline; | ||
.mat-mdc-form-field-subscript-wrapper, | ||
.mat-mdc-form-field label { | ||
.mat-icon { | ||
width: 1em; | ||
height: 1em; | ||
font-size: inherit; | ||
} | ||
} | ||
|
||
// Clears the floats on the hints. This is necessary for the hint animation to work. | ||
|
@@ -47,29 +66,11 @@ | |
// helper text in our MDC based form field | ||
@mixin mat-mdc-private-form-field-subscript-typography($config-or-theme) { | ||
$config: mat-get-typography-config($config-or-theme); | ||
// The unit-less line-height from the font config. | ||
$line-height: mat-line-height($config, input); | ||
// The amount to scale the font for the subscript. | ||
$subscript-font-scale: 0.75; | ||
// Font size to use for the subscript text. | ||
$subscript-font-size: $subscript-font-scale * 100%; | ||
// The space between the bottom of the text-field area and the subscript. Mocks in the spec show | ||
// half of the text size, but this margin is applied to an element with the subscript text font | ||
// size, so we need to divide by the scale factor to make it half of the original text size. | ||
$subscript-margin-top: 0.5em / $subscript-font-scale; | ||
// The minimum height applied to the subscript to reserve space for subscript text. This is a | ||
// combination of the subscript's margin and line-height, but we need to multiply by the | ||
// subscript font scale factor since the subscript has a reduced font size. | ||
$subscript-min-height: ($subscript-margin-top + $line-height) * $subscript-font-scale; | ||
// The horizontal padding between the edge of the text box and the start of the subscript text. | ||
$subscript-horizontal-padding: 16px; | ||
|
||
// The subscript wrapper has a minimum height to avoid that the form-field | ||
// jumps when hints or errors are displayed. | ||
.mat-mdc-form-field-subscript-wrapper { | ||
min-height: $subscript-min-height; | ||
font-size: $subscript-font-size; | ||
margin-top: $subscript-margin-top; | ||
padding: 0 $subscript-horizontal-padding; | ||
.mat-mdc-form-field-subscript-wrapper, | ||
.mat-mdc-form-field-bottom-align::before { | ||
@include mdc-typography(caption, $query: $mat-typography-styles-query); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,15 +9,18 @@ | |
@mixin mat-mdc-private-text-field-structure-overrides() { | ||
// Unset the border set by MDC. We move the border (which serves as the Material Design | ||
// text-field bottom line) into its own element. This is necessary because we want the | ||
// bottom-line to span across the whole form-field (including prefixes and suffixes). Also | ||
// we ensure that font styles are inherited for input elements. We do this because inputs by | ||
// default have explicit font styles from the user agent, and we set the desired font styles | ||
// in the parent `mat-form-field` element (for better custom form-field control support). | ||
// bottom-line to span across the whole form-field (including prefixes and suffixes). | ||
.mat-mdc-input-element { | ||
font: inherit; | ||
border: none; | ||
} | ||
|
||
// In order to ensure proper alignment of the floating label, we reset its line-height. | ||
// The line-height is not important as the element is absolutely positioned and only has one line | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of saying "is not important", would it be accurate to say "doesn't affect the size of the element" ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not really, it does affect the size of the element - its just that we absolutely position the element, so the size doesn't affect the rest of the layout, and its not important as far as the line spacing since labels are only one line anyways |
||
// of text. | ||
.mat-mdc-form-field .mdc-floating-label { | ||
line-height: normal; | ||
} | ||
|
||
// Reset the height that MDC sets on native input elements. We cannot rely on their | ||
// fixed height as we handle vertical spacing differently. MDC sets a fixed height for | ||
// inputs and modifies the baseline so that the textfield matches the spec. This does | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a bug filed for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have an internal one filed against our gmat components - the difference is almost imperceptible with the external spec, just the letter spacing is different. I haven't opened an bug against MDC yet.