@@ -18,7 +18,8 @@ $mat-theme-styles-query: color;
1818$mat-typography-styles-query : typography;
1919
2020// Mappings between Angular Material and MDC's typography levels.
21- $mat-typography-level-mappings : (
21+ // TODO: delete once all MDC components have migrated to using the 2018 mappings.
22+ $mat-typography-2014-level-mappings : (
2223 mdc-to-mat : (
2324 headline1 : display- 4,
2425 headline2 : display- 3,
@@ -51,9 +52,45 @@ $mat-typography-level-mappings: (
5152 )
5253);
5354
55+ // Mappings between Angular Material and MDC's typography levels.
56+ $mat-typography-2018-level-mappings : (
57+ mdc-to-mat : (
58+ headline1 : headline- 1,
59+ headline2 : headline- 2,
60+ headline3 : headline- 3,
61+ headline4 : headline- 4,
62+ headline5 : headline- 5,
63+ headline6 : headline- 6,
64+ subtitle1 : subtitle- 1,
65+ subtitle2 : subtitle- 2,
66+ body1 : body- 1,
67+ body2 : body- 2,
68+ caption : caption ,
69+ button : button,
70+ overline : overline
71+ ),
72+ mat-to-mdc : (
73+ headline-1 : headline1,
74+ headline-2 : headline2,
75+ headline-3 : headline3,
76+ headline-4 : headline4,
77+ headline-5 : headline5,
78+ headline-6 : headline6,
79+ subtitle-1 : subtitle1,
80+ subtitle-2 : subtitle2,
81+ body-1 : body1,
82+ body-2 : body2,
83+ caption : caption ,
84+ button : button,
85+ overline : overline
86+ )
87+ );
88+
5489// Converts an Angular Material typography level config to an MDC one.
5590@function mat-typography-level-config-to-mdc ($mat-config , $mat-level ) {
56- $mdc-level : map-get (map-get ($mat-typography-level-mappings , mat-to-mdc ), $mat-level );
91+ $mappings : if (mat-private-typography-is-2018-config ($mat-config ),
92+ $mat-typography-2018-level-mappings , $mat-typography-2014-level-mappings );
93+ $mdc-level : map-get (map-get ($mappings , mat-to-mdc ), $mat-level );
5794
5895 @return map-merge (
5996 if ($mdc-level ,
@@ -81,7 +118,10 @@ $mat-typography-level-mappings: (
81118@function mat-typography-config-to-mdc ($mat-config : mat-typography-config ()) {
82119 $mdc-config : ();
83120
84- @each $mdc-level , $mat-level in map-get ($mat-typography-level-mappings , mdc-to-mat ) {
121+ $mappings : if (mat-private-typography-is-2018-config ($mat-config ),
122+ $mat-typography-2018-level-mappings , $mat-typography-2014-level-mappings );
123+
124+ @each $mdc-level , $mat-level in map-get ($mappings , mdc-to-mat ) {
85125 $mdc-config : map-merge (
86126 $mdc-config ,
87127 ($mdc-level : mat-typography-level-config-to-mdc ($mat-config , $mat-level )));
@@ -100,17 +140,6 @@ $mat-typography-level-mappings: (
100140 map-get ($mdc-typography-styles , letter-spacing ));
101141}
102142
103- // Converts an MDC typography config to an Angular Material one.
104- @function mat-typography-config-from-mdc () {
105- $mat-config : ();
106-
107- @each $mat-level , $mdc-level in map-get ($mat-typography-level-mappings , mat-to-mdc ) {
108- $mat-config : map-merge ($mat-config , mat-typography-config-from-mdc ($mdc-level ));
109- }
110-
111- @return $mat-config ;
112- }
113-
114143// Configures MDC's global variables to reflect the given theme, applies the given styles,
115144// then resets the global variables to prevent unintended side effects.
116145/* stylelint-disable-next-line material/theme-mixin-api */
0 commit comments