Skip to content

Commit a9a61f0

Browse files
committed
refactor: take 2014 config into account
1 parent 54ad6fc commit a9a61f0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/material/core/tokens/m2/_md-sys-typescale.scss

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
@use 'sass:map';
2+
@use 'sass:string';
3+
@use 'sass:meta';
24

35
@function md-sys-typescale-values($config) {
46
$sys-to-config: (
@@ -19,9 +21,34 @@
1921
title-small: headline-6,
2022
);
2123

24+
// If the config is based on an old 2014 version of the typography spec, then
25+
// use the old config keys to map to the new system tokens.
26+
@if (map.get($config, headline) != null) {
27+
$sys-to-config: (
28+
body-large: subheading-1,
29+
body-medium: body-1,
30+
body-small: caption,
31+
display-large: display-4,
32+
display-medium: display-4,
33+
display-small: display-4,
34+
headline-large: display-3,
35+
headline-medium: display-2,
36+
headline-small: display-1,
37+
label-large: subheading-2,
38+
label-medium: body-2,
39+
label-small: button,
40+
title-large: headline,
41+
title-medium: headline,
42+
title-small: title,
43+
);
44+
}
45+
2246
$typography: ();
2347
@each $sys-key, $config-key in $sys-to-config {
2448
$font: map.get($config, $config-key, font-family);
49+
@if (meta.type-of($font) == 'string') {
50+
$font: string.unquote($font);
51+
}
2552
$line-height: map.get($config, $config-key, line-height);
2653
$size: map.get($config, $config-key, font-size);
2754
$tracking: map.get($config, $config-key, letter-spacing);

0 commit comments

Comments
 (0)