Skip to content

Commit 8bcca6b

Browse files
committed
feat(material/core): add typography config normalization function
1 parent 94bd0d4 commit 8bcca6b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/material/core/typography/_typography.scss

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,37 @@
6969
@return map-merge($config, (font-family: $font-family));
7070
}
7171

72+
// Whether a config is for the Material Design 2018 typography system.
73+
@function mat-private-typography-is-2018-config($config) {
74+
@if map-get($config, headline-1) {
75+
@return true;
76+
}
77+
@return false;
78+
}
79+
80+
// Given a config for either the 2014 or 2018 Material Design typography system,
81+
// produces a normalized typography config for the 2014 Material Design typography system.
82+
// 2014 - https://material.io/archive/guidelines/style/typography.html#typography-styles
83+
// 2018 - https://material.io/design/typography/the-type-system.html#type-scale
84+
@function mat-typography-normalized-config($config) {
85+
@if mat-private-typography-is-2018-config($config) {
86+
@return mat-typography-config(
87+
$display-3: map-get($config, display-1),
88+
$display-2: map-get($config, display-2),
89+
$display-1: map-get($config, display-3),
90+
$headline: map-get($config, headline-4),
91+
$title: map-get($config, subtitle-1),
92+
$subheading-2: map-get($config, subhead-1),
93+
$subheading-1: map-get($config, subhead-2),
94+
$body-2: map-get($config, body-1),
95+
$body-1: map-get($config, body-2),
96+
$caption: map-get($config, caption),
97+
$button: map-get($config, button),
98+
);
99+
}
100+
@return $config;
101+
}
102+
72103
// Adds the base typography styles, based on a config.
73104
/* stylelint-disable-next-line material/theme-mixin-api */
74105
@mixin mat-base-typography($config, $selector: '.mat-typography') {

0 commit comments

Comments
 (0)