Skip to content

Commit 08206fc

Browse files
committed
refactor(material/typography): Move define-typography-config under _typography.scss (#27195)
* refactor(material/typography): Move define-typography-config under _typography.scss This never should have been under _all-typography.scss to begin with. _all-typography.scss depends on all of the component themes, which prevents any of the component themes from using this function as it would cause a circular dep. Instead, moving it under _typography.scss where the legacy version lives makes much more sense. * fixup! refactor(material/typography): Move define-typography-config under _typography.scss (cherry picked from commit 3749308)
1 parent f35141a commit 08206fc

16 files changed

+199
-214
lines changed

src/material/_index.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
$amber-palette, $orange-palette, $deep-orange-palette, $brown-palette, $grey-palette,
1010
$gray-palette, $blue-grey-palette, $blue-gray-palette, $light-theme-background-palette,
1111
$dark-theme-background-palette, $light-theme-foreground-palette, $dark-theme-foreground-palette;
12-
@forward './core/typography/typography' show define-typography-level,
13-
define-legacy-typography-config, legacy-typography-hierarchy, typography-hierarchy;
12+
@forward './core/typography/typography' show define-typography-level, define-rem-typography-config,
13+
define-typography-config, typography-hierarchy, define-legacy-typography-config,
14+
legacy-typography-hierarchy;
1415
@forward './core/typography/typography-utils' show typography-level,
1516
font-size, line-height, font-weight, letter-spacing, font-family, font-shorthand;
1617

@@ -48,8 +49,7 @@
4849
// Theme bundles
4950
@forward './core/theming/all-theme' show all-component-themes;
5051
@forward './core/color/all-color' show all-component-colors;
51-
@forward './core/typography/all-typography' show all-component-typographies,
52-
define-rem-typography-config, define-typography-config;
52+
@forward './core/typography/all-typography' show all-component-typographies;
5353
@forward './legacy-core/theming/all-theme' show all-legacy-component-themes;
5454
@forward './legacy-core/color/all-color' show all-legacy-component-colors;
5555
@forward './legacy-core/typography/all-typography' show all-legacy-component-typographies;

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

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,6 @@ $mat-typography-mdc-level-mappings: (
8383
@return $mdc-config;
8484
}
8585

86-
// Converts an MDC typography level config to an Angular Material one.
87-
@function typography-config-level-from-mdc($mdc-level, $font-family: null) {
88-
$mdc-level-config: map.get(mdc-typography.$styles, $mdc-level);
89-
90-
// Explicitly default the font family to null since we'll apply it globally
91-
// through the `define-typgraphy-config`/`define-legacy-typography-config`.
92-
@return typography.define-typography-level(
93-
$font-family: $font-family,
94-
$font-size: map.get($mdc-level-config, font-size),
95-
$line-height: map.get($mdc-level-config, line-height),
96-
$font-weight: map.get($mdc-level-config, font-weight),
97-
$letter-spacing: map.get($mdc-level-config, letter-spacing)
98-
);
99-
}
100-
10186
// MDC logs a warning if the `contrast-tone` function is called with a CSS variable.
10287
// This function falls back to determining the tone based on whether the theme is light or dark.
10388
@function _variable-safe-contrast-tone($value, $is-dark) {
@@ -238,19 +223,19 @@ $mat-typography-mdc-level-mappings: (
238223
$font-family: mdc-typography.$font-family;
239224
@return (
240225
font-family: $font-family,
241-
headline-1: typography-config-level-from-mdc(headline1, $font-family),
242-
headline-2: typography-config-level-from-mdc(headline2, $font-family),
243-
headline-3: typography-config-level-from-mdc(headline3, $font-family),
244-
headline-4: typography-config-level-from-mdc(headline4, $font-family),
245-
headline-5: typography-config-level-from-mdc(headline5, $font-family),
246-
headline-6: typography-config-level-from-mdc(headline6, $font-family),
247-
subtitle-1: typography-config-level-from-mdc(subtitle1, $font-family),
248-
subtitle-2: typography-config-level-from-mdc(subtitle2, $font-family),
249-
body-1: typography-config-level-from-mdc(body1, $font-family),
250-
body-2: typography-config-level-from-mdc(body2, $font-family),
251-
caption: typography-config-level-from-mdc(caption, $font-family),
252-
button: typography-config-level-from-mdc(button, $font-family),
253-
overline: typography-config-level-from-mdc(overline, $font-family),
226+
headline-1: typography.typography-config-level-from-mdc(headline1, $font-family),
227+
headline-2: typography.typography-config-level-from-mdc(headline2, $font-family),
228+
headline-3: typography.typography-config-level-from-mdc(headline3, $font-family),
229+
headline-4: typography.typography-config-level-from-mdc(headline4, $font-family),
230+
headline-5: typography.typography-config-level-from-mdc(headline5, $font-family),
231+
headline-6: typography.typography-config-level-from-mdc(headline6, $font-family),
232+
subtitle-1: typography.typography-config-level-from-mdc(subtitle1, $font-family),
233+
subtitle-2: typography.typography-config-level-from-mdc(subtitle2, $font-family),
234+
body-1: typography.typography-config-level-from-mdc(body1, $font-family),
235+
body-2: typography.typography-config-level-from-mdc(body2, $font-family),
236+
caption: typography.typography-config-level-from-mdc(caption, $font-family),
237+
button: typography.typography-config-level-from-mdc(button, $font-family),
238+
overline: typography.typography-config-level-from-mdc(overline, $font-family),
254239
);
255240
}
256241

src/material/core/theming/prebuilt/deeppurple-amber.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
@use '../../core';
33
@use '../palette';
44
@use '../theming';
5-
@use '../../typography/all-typography';
65
@use '../../typography/typography';
76

87
// Include non-theme styles for core.
@@ -17,7 +16,7 @@ $theme: theming.define-light-theme((
1716
primary: $primary,
1817
accent: $accent,
1918
),
20-
typography: all-typography.define-typography-config(),
19+
typography: typography.define-typography-config(),
2120
density: 0,
2221
));
2322

src/material/core/theming/prebuilt/indigo-pink.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
@use '../../core';
33
@use '../palette';
44
@use '../theming';
5-
@use '../../typography/all-typography';
65
@use '../../typography/typography';
76

87

@@ -18,7 +17,7 @@ $theme: theming.define-light-theme((
1817
primary: $primary,
1918
accent: $accent
2019
),
21-
typography: all-typography.define-typography-config(),
20+
typography: typography.define-typography-config(),
2221
density: 0,
2322
));
2423

src/material/core/theming/prebuilt/pink-bluegrey.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
@use '../../core';
33
@use '../palette';
44
@use '../theming';
5-
@use '../../typography/all-typography';
65
@use '../../typography/typography';
76

87

@@ -18,7 +17,7 @@ $theme: theming.define-dark-theme((
1817
primary: $primary,
1918
accent: $accent
2019
),
21-
typography: all-typography.define-typography-config(),
20+
typography: typography.define-typography-config(),
2221
density: 0,
2322
));
2423

src/material/core/theming/prebuilt/purple-green.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
@use '../../core';
33
@use '../palette';
44
@use '../theming';
5-
@use '../../typography/all-typography';
65
@use '../../typography/typography';
76

87

@@ -18,7 +17,7 @@ $theme: theming.define-dark-theme((
1817
primary: $primary,
1918
accent: $accent
2019
),
21-
typography: all-typography.define-typography-config(),
20+
typography: typography.define-typography-config(),
2221
density: 0,
2322
));
2423

src/material/core/theming/tests/test-css-variables-theme.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@use 'sass:map';
22
@use 'sass:meta';
33
@use '../all-theme';
4-
@use '../../typography/all-typography';
4+
@use '../../typography/typography';
55
@use '../palette';
66
@use '../theming';
77
@use '../../../legacy-core/theming/all-theme' as legacy-all-theme;
@@ -31,7 +31,7 @@
3131
accent: $palette,
3232
warn: $palette
3333
),
34-
typography: all-typography.define-typography-config(),
34+
typography: typography.define-typography-config(),
3535
));
3636
$css-var-theme: _replace-all-values($theme, var(--test-var));
3737
@include all-theme.all-component-themes($css-var-theme);

src/material/core/theming/tests/test-theming-api.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ $new-api-dark-theme-default-warn: theming.define-dark-theme((
6666
$light-theme-only-density: theming.define-light-theme((density: -2));
6767
$dark-theme-only-density: theming.define-dark-theme((density: -2));
6868

69-
$typography-config: all-typography.define-typography-config();
69+
$typography-config: typography.define-typography-config();
7070
$light-theme-only-typography: theming.define-light-theme((typography: $typography-config));
7171
$dark-theme-only-typography: theming.define-dark-theme((typography: $typography-config));
7272

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@use '@material/typography' as mdc-typography;
2-
@use '../../typography/all-typography';
32
@use '../../typography/typography';
43
@use 'sass:map';
54
@use 'sass:meta';
@@ -16,17 +15,17 @@
1615

1716
$no-font-family: assert-font-family(
1817
'should take default MDC font family if none is specified',
19-
all-typography.define-typography-config(),
18+
typography.define-typography-config(),
2019
mdc-typography.$font-family);
2120

2221
$only-top-level-font-family: assert-font-family(
2322
'should take custom font family if specified at top level',
24-
all-typography.define-typography-config($font-family: 'custom-top'),
23+
typography.define-typography-config($font-family: 'custom-top'),
2524
'custom-top');
2625

2726
$individual-levels-without-font-families: assert-font-family(
2827
'should set the default MDC font family if all keys are specified, but without a font-family',
29-
all-typography.define-typography-config(
28+
typography.define-typography-config(
3029
$headline-1: typography.define-typography-level($font-size: 1px),
3130
$headline-2: typography.define-typography-level($font-size: 1px),
3231
$headline-3: typography.define-typography-level($font-size: 1px),
@@ -46,7 +45,7 @@ $individual-levels-without-font-families: assert-font-family(
4645

4746
$individual-levels-without-font-families-with-top-level-family: assert-font-family(
4847
'should set a custom top-level font family if all keys are specified, but without a font-family',
49-
all-typography.define-typography-config(
48+
typography.define-typography-config(
5049
$font-family: 'custom-top',
5150
$headline-1: typography.define-typography-level($font-size: 1px),
5251
$headline-2: typography.define-typography-level($font-size: 1px),
@@ -67,7 +66,7 @@ $individual-levels-without-font-families-with-top-level-family: assert-font-fami
6766

6867
$individual-levels-with-font-families: assert-font-family(
6968
'should use the level font family if one is specified, but there is none at the top level',
70-
all-typography.define-typography-config(
69+
typography.define-typography-config(
7170
$headline-1: typography.define-typography-level($font-size: 1px, $font-family: 'custom-level'),
7271
$headline-2: typography.define-typography-level($font-size: 1px, $font-family: 'custom-level'),
7372
$headline-3: typography.define-typography-level($font-size: 1px, $font-family: 'custom-level'),
@@ -87,7 +86,7 @@ $individual-levels-with-font-families: assert-font-family(
8786

8887
$individual-levels-with-font-families-and-top-level-family: assert-font-family(
8988
'should use the level font family if a top-level one is specified together with it',
90-
all-typography.define-typography-config(
89+
typography.define-typography-config(
9190
$font-family: 'custom-top',
9291
$headline-1: typography.define-typography-level($font-size: 1px, $font-family: 'custom-level'),
9392
$headline-2: typography.define-typography-level($font-size: 1px, $font-family: 'custom-level'),

src/material/core/tokens/_token-utils.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
@use '@material/theme/custom-properties' as mdc-custom-properties;
44
@use '@material/theme/theme' as mdc-theme;
55
@use '@material/theme/keys' as mdc-keys;
6-
@use '../mdc-helpers/mdc-helpers';
76
@use '../theming/palette';
87
@use '../theming/theming';
8+
@use '../typography/typography';
99

1010
$_placeholder-color-palette: theming.define-palette(palette.$red-palette);
1111

@@ -20,7 +20,7 @@ $placeholder-color-config: (
2020
background: palette.$light-theme-background-palette,
2121
);
2222

23-
$_placeholder-typography-level-config: mdc-helpers.typography-config-level-from-mdc(body1);
23+
$_placeholder-typography-level-config: typography.typography-config-level-from-mdc(body1);
2424

2525
// Placeholder typography config that can be passed to token getter functions when generating token
2626
// slots.

0 commit comments

Comments
 (0)