Skip to content

Commit 62b6263

Browse files
committed
refactor(multiple): remove dependency on external typography utilities
Reduces our reliance on external typography utilities.
1 parent c09a0e4 commit 62b6263

File tree

12 files changed

+62
-27
lines changed

12 files changed

+62
-27
lines changed

src/material/button/button.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
@use '@material/button/button-filled-theme' as mdc-button-filled-theme;
66
@use '@material/button/button-protected-theme' as mdc-button-protected-theme;
77
@use '@material/button/button-outlined-theme' as mdc-button-outlined-theme;
8-
@use '@material/typography/typography' as mdc-typography;
98
@use '@material/theme/custom-properties' as mdc-custom-properties;
109

1110
@use './button-base';
@@ -155,7 +154,7 @@
155154
// Similar to MDC's `_icon-structure`, apart from the margin which we
156155
// handle via custom tokens in `mat-private-button-horizontal-layout`.
157156
& > .mat-icon {
158-
$icon-size: mdc-typography.px-to-rem(18px);
157+
$icon-size: 1.125rem;
159158
display: inline-block;
160159
position: relative;
161160
vertical-align: top;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
@use '@material/form-field/form-field' as mdc-form-field;
2-
@use '@material/typography/typography' as mdc-typography;
32
@use '@material/theme/custom-properties' as mdc-custom-properties;
3+
@use '../style/vendor-prefixes';
44
@use '../mdc-helpers/mdc-helpers';
55

66
@include mdc-custom-properties.configure($emit-fallback-values: false, $emit-fallback-vars: false) {
77
@include mdc-form-field.static-styles($query: mdc-helpers.$mdc-base-styles-query);
88
}
99

1010
.mat-internal-form-field {
11-
@include mdc-typography.smooth-font();
11+
@include vendor-prefixes.smooth-font();
1212
}

src/material/core/m2/_typography.scss

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
@use 'sass:map';
22
@use 'sass:math';
33
@use 'sass:meta';
4+
@use 'sass:string';
45
@use '@material/typography' as mdc-typography;
56

7+
$_default-font-family: string.unquote('Roboto, sans-serif');
8+
69
/// Defines a typography level from the Material Design spec.
710
/// @param {String} $font-size The font-size for this level.
811
/// @param {String | Number} $line-height The line-height for this level.
@@ -123,7 +126,7 @@
123126
@function define-typography-config(
124127
// TODO(mmalerba): rename this function to define-typography-config,
125128
// and create a predefined px based config for people that need it.
126-
$font-family: mdc-typography.$font-family,
129+
$font-family: $_default-font-family,
127130
$headline-1: null,
128131
$headline-2: null,
129132
$headline-3: null,
@@ -180,7 +183,7 @@
180183
@function define-rem-typography-config(
181184
// TODO(mmalerba): rename this function to define-typography-config,
182185
// and create a predefined px based config for people that need it.
183-
$font-family: mdc-typography.$font-family,
186+
$font-family: $_default-font-family,
184187
$headline-1: null,
185188
$headline-2: null,
186189
$headline-3: null,

src/material/core/mdc-helpers/_mdc-helpers.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// TODO(mmalerba): this file should be split into separate cohesive partials for things like
22
// "theming", "typography", "core".
3+
@use 'sass:string';
34
@use '../typography/typography';
45
@use '@material/feature-targeting' as mdc-feature-targeting;
5-
@use '@material/typography' as mdc-typography;
66
@use '@material/theme/theme-color' as mdc-theme-color;
77
@use '@material/theme/css' as mdc-theme-css;
88

@@ -32,7 +32,7 @@ $mdc-typography-styles-query: typography;
3232
@function private-fallback-typography-from-mdc() {
3333
// This is very close to what we have in `define-typography-config`, but we can't use it here,
3434
// because it would cause a circular import and moving it here doesn't make sense.
35-
$font-family: mdc-typography.$font-family;
35+
$font-family: string.unquote('Roboto, sans-serif');
3636
@return (
3737
font-family: $font-family,
3838
headline-1: typography.typography-config-level-from-mdc(headline1, $font-family),

src/material/core/theming/tests/test-typography-font-family.scss

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
@use '@material/typography' as mdc-typography;
2-
@use '../../m2/typography' as m2-typography;
1+
@use 'sass:string';
32
@use 'sass:map';
43
@use 'sass:meta';
4+
@use '../../m2/typography' as m2-typography;
5+
6+
$_font-family: string.unquote('Roboto, sans-serif');
57

68
@function assert-font-family($test-name, $obj, $expected) {
79
@each $level-name, $level in $obj {
@@ -16,7 +18,7 @@
1618
$no-font-family: assert-font-family(
1719
'should take default MDC font family if none is specified',
1820
m2-typography.define-typography-config(),
19-
mdc-typography.$font-family);
21+
$_font-family);
2022

2123
$only-top-level-font-family: assert-font-family(
2224
'should take custom font family if specified at top level',
@@ -40,7 +42,7 @@ $individual-levels-without-font-families: assert-font-family(
4042
$button: m2-typography.define-typography-level($font-size: 1px),
4143
$overline: m2-typography.define-typography-level($font-size: 1px),
4244
),
43-
mdc-typography.$font-family
45+
$_font-family
4446
);
4547

4648
$individual-levels-without-font-families-with-top-level-family: assert-font-family(

src/material/dialog/dialog.scss

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@use '@angular/cdk';
2-
@use '@material/typography/typography' as mdc-typography;
32
@use '../core/tokens/m2/mdc/dialog' as tokens-mdc-dialog;
43
@use '../core/tokens/m2/mat/dialog' as tokens-mat-dialog;
54
@use '../core/mdc-helpers/mdc-helpers';
@@ -153,12 +152,23 @@ $_emit-fallbacks: true;
153152
}
154153

155154
.mat-mdc-dialog-title {
156-
@include mdc-typography.text-baseline($top: 40px, $display: block, $lineHeight: null);
155+
display: block;
157156
position: relative;
158157
flex-shrink: 0;
159158
box-sizing: border-box;
160159
margin: 0 0 1px;
161160

161+
// This was used by MDC to set the text baseline. We should figure out a way to
162+
// remove it, because it can introduce unnecessary whitespace at the beginning
163+
// of the element.
164+
&::before {
165+
display: inline-block;
166+
width: 0;
167+
height: 40px;
168+
content: '';
169+
vertical-align: 0;
170+
}
171+
162172
[dir='rtl'] & {
163173
text-align: right;
164174
}

src/material/form-field/_form-field-subscript.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
@use '@material/typography' as mdc-typography;
21
@use '@material/textfield/variables' as mdc-textfield-variables;
32

43
@use '../core/tokens/m2/mat/form-field' as tokens-mat-form-field;
4+
@use '../core/style/vendor-prefixes';
55
@use '../core/tokens/token-utils';
66

77
@mixin private-form-field-subscript() {
@@ -68,7 +68,7 @@
6868
.mat-mdc-form-field-bottom-align::before {
6969
@include token-utils.use-tokens(tokens-mat-form-field.$prefix,
7070
tokens-mat-form-field.get-token-slots()) {
71-
@include mdc-typography.smooth-font();
71+
@include vendor-prefixes.smooth-font();
7272
@include token-utils.create-token-slot(font-family, subscript-text-font);
7373
@include token-utils.create-token-slot(line-height, subscript-text-line-height);
7474
@include token-utils.create-token-slot(font-size, subscript-text-size);

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@use '@material/textfield/variables' as mdc-textfield-variables;
2-
@use '@material/typography/typography' as mdc-typography;
32
@use '../core/tokens/m2/mat/form-field' as tokens-mat-form-field;
43
@use '../core/tokens/token-utils';
54
@use '../core/style/vendor-prefixes';
@@ -25,7 +24,7 @@ $_enable-form-field-will-change-reset: true;
2524
// Note: We increase specificity here because the MDC textfield seems to override this,
2625
// depending on the CSS order, with an affix selector joint with the input.
2726
.mat-mdc-form-field-input-control.mat-mdc-form-field-input-control {
28-
@include mdc-typography.smooth-font();
27+
@include vendor-prefixes.smooth-font();
2928
font: inherit;
3029
letter-spacing: inherit;
3130
text-decoration: inherit;
@@ -34,7 +33,7 @@ $_enable-form-field-will-change-reset: true;
3433
}
3534

3635
.mat-mdc-form-field .mat-mdc-floating-label.mdc-floating-label {
37-
@include mdc-typography.smooth-font();
36+
@include vendor-prefixes.smooth-font();
3837

3938
// In order to ensure proper alignment of the floating label, we reset its line-height.
4039
// The line-height is not important as the element is absolutely positioned and only has one

src/material/form-field/form-field.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
@use '@material/line-ripple/line-ripple' as mdc-line-ripple;
99
@use '@material/line-ripple/line-ripple-theme' as mdc-line-ripple-theme;
1010
@use '@material/theme/custom-properties' as mdc-custom-properties;
11-
@use '@material/typography' as mdc-typography;
1211
@use '../core/tokens/token-utils';
1312
@use '../core/mdc-helpers/mdc-helpers';
1413
@use '../core/style/vendor-prefixes';
@@ -91,7 +90,7 @@ $_icon-prefix-infix-padding: 4px;
9190

9291
@include token-utils.use-tokens(tokens-mat-form-field.$prefix,
9392
tokens-mat-form-field.get-token-slots()) {
94-
@include mdc-typography.smooth-font();
93+
@include vendor-prefixes.smooth-font();
9594
@include token-utils.create-token-slot(font-family, container-text-font);
9695
@include token-utils.create-token-slot(line-height, container-text-line-height);
9796
@include token-utils.create-token-slot(font-size, container-text-size);

src/material/list/_list-option-trailing-avatar-compat.scss

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@use '@material/typography/typography';
21
@use '@material/feature-targeting/feature-targeting';
32
@use '@material/density/functions' as density-functions;
43
@use '@material/list/evolution-mixins' as mdc-list;
@@ -22,8 +21,33 @@
2221
@include mdc-list.item-end-size(40px, $query: $query);
2322

2423
&.mdc-list-item--with-two-lines {
24+
$top: 32px;
25+
$bottom: 20px;
26+
2527
.mdc-list-item__primary-text {
26-
@include typography.text-baseline($top: 32px, $bottom: 20px, $query: $query);
28+
display: block;
29+
margin-top: 0;
30+
line-height: normal;
31+
margin-bottom: $bottom * -1;
32+
33+
// This was used by MDC to set the text baseline. We should figure out a way to
34+
// remove it, because it can introduce unnecessary whitespace at the beginning
35+
// of the element.
36+
&::before {
37+
display: inline-block;
38+
width: 0;
39+
height: $top;
40+
content: '';
41+
vertical-align: 0;
42+
}
43+
44+
&::after {
45+
display: inline-block;
46+
width: 0;
47+
height: $bottom;
48+
content: '';
49+
vertical-align: $bottom * -1;
50+
}
2751
}
2852
}
2953

src/material/paginator/paginator.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@use '@angular/cdk';
2-
@use '@material/typography/typography' as mdc-typography;
32
@use '../core/tokens/m2/mat/paginator' as tokens-mat-paginator;
43
@use '../core/tokens/token-utils';
4+
@use '../core/style/vendor-prefixes';
55

66
$padding: 0 8px;
77
$page-size-margin-right: 8px;
@@ -21,7 +21,7 @@ $button-icon-size: 28px;
2121
tokens-mat-paginator.$prefix,
2222
tokens-mat-paginator.get-token-slots()
2323
) {
24-
@include mdc-typography.smooth-font();
24+
@include vendor-prefixes.smooth-font();
2525
@include token-utils.create-token-slot(color, container-text-color);
2626
@include token-utils.create-token-slot(background-color, container-background-color);
2727
@include token-utils.create-token-slot(font-family, container-text-font);

src/material/select/select.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@use 'sass:math';
22
@use '@angular/cdk';
3-
@use '@material/typography/typography' as mdc-typography;
43
@use '../core/style/vendor-prefixes';
54
@use '../core/style/variables';
65
@use '../core/tokens/token-utils';
@@ -22,7 +21,7 @@ $scale: 0.75 !default;
2221

2322
@include token-utils.use-tokens(
2423
tokens-mat-select.$prefix, tokens-mat-select.get-token-slots()) {
25-
@include mdc-typography.smooth-font();
24+
@include vendor-prefixes.smooth-font();
2625
@include token-utils.create-token-slot(color, enabled-trigger-text-color);
2726
@include token-utils.create-token-slot(font-family, trigger-text-font);
2827
@include token-utils.create-token-slot(line-height, trigger-text-line-height);

0 commit comments

Comments
 (0)