Skip to content

Commit 08b60ab

Browse files
committed
fix(material-experimental/mdc-typography): update incorrect levels
Note: card, dialog, and form-field still don't look right according to the spec. While they're now using the correct font level, the levels for body1 and body2 themselves do not match the spec. This will be addressed in a followup PR.
1 parent 6973785 commit 08b60ab

File tree

6 files changed

+43
-13
lines changed

6 files changed

+43
-13
lines changed

src/material-experimental/mdc-autocomplete/_autocomplete-theme.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@import '@material/menu-surface/mixins.import';
22
@import '@material/list/mixins.import';
3+
@import '@material/typography/mixins.import';
34
@import '../mdc-helpers/mdc-helpers';
45

56
@mixin mat-mdc-autocomplete-color($config-or-theme) {
@@ -19,6 +20,12 @@
1920
// Note that we include this private mixin, because the public one adds
2021
// a bunch of styles that we aren't using for the autocomplete panel.
2122
@include mdc-list-base_($mat-typography-styles-query);
23+
24+
// MDC uses the `subtitle1` level for list items, but the spec shows `body1` as the correct
25+
// level.
26+
.mat-mdc-option {
27+
@include mdc-typography(body1, $query: $mat-typography-styles-query);
28+
}
2229
}
2330
}
2431
}

src/material-experimental/mdc-form-field/_form-field-sizing.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ $mat-form-field-input-box-vertical-offset: 1px;
3636
// spacing as provided by the Material Design specification. The outlined dimensions in the
3737
// spec section do not match with the text fields shown in the overview or the ones implemented
3838
// by MDC. Note that we need to account for the input box offset. See above for more context.
39-
$mat-form-field-with-label-input-padding-top: 28px - $mat-form-field-input-box-vertical-offset;
40-
$mat-form-field-with-label-input-padding-bottom: 12px - $mat-form-field-input-box-vertical-offset;
39+
$mat-form-field-with-label-input-padding-top: 24px - $mat-form-field-input-box-vertical-offset;
40+
$mat-form-field-with-label-input-padding-bottom: 8px - $mat-form-field-input-box-vertical-offset;
4141

4242
// Vertical spacing of the text-field if there is no label. We manually measure the
4343
// spacing in the specs. See comment above for padding for text fields with label. The
4444
// same reasoning applies to the padding for text fields without label.
45-
$mat-form-field-no-label-padding-bottom: 20px - $mat-form-field-input-box-vertical-offset;
46-
$mat-form-field-no-label-padding-top: 20px - $mat-form-field-input-box-vertical-offset;
45+
$mat-form-field-no-label-padding-bottom: 16px - $mat-form-field-input-box-vertical-offset;
46+
$mat-form-field-no-label-padding-top: 16px - $mat-form-field-input-box-vertical-offset;

src/material-experimental/mdc-form-field/_form-field-theme.scss

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
@import '@material/theme/variables.import';
55
@import '@material/textfield/mixins.import';
66
@import '@material/textfield/variables.import';
7+
@import '@material/typography/mixins.import';
78
@import '../mdc-helpers/mdc-helpers';
89
@import 'form-field-density';
910
@import 'form-field-subscript';
@@ -22,8 +23,8 @@
2223

2324
.mdc-text-field--focused {
2425
@include mdc-text-field-focused_($query);
25-
2626
}
27+
2728
.mdc-text-field--invalid {
2829
@include mdc-text-field-invalid_($query);
2930
}
@@ -67,8 +68,13 @@
6768
@include mdc-line-ripple-core-styles($query: $mat-typography-styles-query);
6869
@include mat-mdc-private-form-field-subscript-typography($config);
6970

70-
.mat-mdc-form-field {
71-
@include mat-typography-level-to-styles($config, input);
71+
// MDC uses the `subtitle1` level for the input label and value, but the spec shows `body1` as
72+
// the correct level.
73+
.mat-mdc-input-element,
74+
.mat-mdc-form-field label,
75+
.mat-mdc-form-field-prefix,
76+
.mat-mdc-form-field-suffix {
77+
@include mdc-typography(body1, $query: $mat-typography-styles-query);
7278
}
7379
}
7480
}

src/material-experimental/mdc-form-field/_mdc-text-field-structure-overrides.scss

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@
99
@mixin mat-mdc-private-text-field-structure-overrides() {
1010
// Unset the border set by MDC. We move the border (which serves as the Material Design
1111
// text-field bottom line) into its own element. This is necessary because we want the
12-
// bottom-line to span across the whole form-field (including prefixes and suffixes). Also
13-
// we ensure that font styles are inherited for input elements. We do this because inputs by
14-
// default have explicit font styles from the user agent, and we set the desired font styles
15-
// in the parent `mat-form-field` element (for better custom form-field control support).
12+
// bottom-line to span across the whole form-field (including prefixes and suffixes).
1613
.mat-mdc-input-element {
17-
font: inherit;
1814
border: none;
1915
}
2016

17+
// In order to ensure proper alignment of the floating label, we reset its line-height.
18+
// The line-height is not important as the element is absolutely positioned and only has one line
19+
// of text.
20+
.mat-mdc-form-field .mdc-floating-label {
21+
line-height: normal;
22+
}
23+
2124
// Reset the height that MDC sets on native input elements. We cannot rely on their
2225
// fixed height as we handle vertical spacing differently. MDC sets a fixed height for
2326
// inputs and modifies the baseline so that the textfield matches the spec. This does

src/material-experimental/mdc-menu/_menu-theme.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
@import '@material/list/variables.import';
55
@import '@material/theme/functions.import';
66
@import '@material/theme/mixins.import';
7+
@import '@material/typography/mixins.import';
78
@import '../mdc-helpers/mdc-helpers';
89

910
@mixin mat-mdc-menu-color($config-or-theme) {
@@ -47,10 +48,16 @@
4748
@include mat-using-mdc-typography($config) {
4849
@include mdc-menu-surface-core-styles($mat-typography-styles-query);
4950

50-
.mat-mdc-menu-content, .mat-mdc-menu-item {
51+
.mat-mdc-menu-content {
5152
// Note that we include this private mixin, because the public
5253
// one adds a bunch of styles that we aren't using for the menu.
5354
@include mdc-list-base_($mat-typography-styles-query);
55+
56+
// MDC uses the `subtitle1` level for list items, but the spec shows `body1` as the correct
57+
// level.
58+
.mat-mdc-menu-item {
59+
@include mdc-typography(body1, $query: $mat-typography-styles-query);
60+
}
5461
}
5562
}
5663
}

src/material-experimental/mdc-select/_select-theme.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@import '@material/list/mixins.import';
33
@import '@material/theme/variables.import';
44
@import '@material/select/variables.import';
5+
@import '@material/typography/mixins.import';
56
@import '../mdc-helpers/mdc-helpers';
67

78
// Gets the color to use for some text that is highlighted while a select has focus.
@@ -88,6 +89,12 @@
8889
// Note that we include this private mixin, because the public one adds
8990
// a bunch of styles that we aren't using for the select panel.
9091
@include mdc-list-base_($mat-typography-styles-query);
92+
93+
// MDC uses the `subtitle1` level for list items, but the spec shows `body1` as the correct
94+
// level.
95+
.mat-mdc-option {
96+
@include mdc-typography(body1, $query: $mat-typography-styles-query);
97+
}
9198
}
9299
}
93100
}

0 commit comments

Comments
 (0)