@@ -18,7 +18,8 @@ $mat-theme-styles-query: color;
18
18
$mat-typography-styles-query : typography;
19
19
20
20
// 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 : (
22
23
mdc-to-mat : (
23
24
headline1 : display- 4,
24
25
headline2 : display- 3,
@@ -51,9 +52,49 @@ $mat-typography-level-mappings: (
51
52
)
52
53
);
53
54
55
+ // Mappings between Angular Material and MDC's typography levels.
56
+ $mat-typography-2018-level-mappings : (
57
+ // Maps from MDC typography levels (e.g. body1) to Angular Material typography levels
58
+ // (e.g. body-1).
59
+ mdc-to-mat : (
60
+ headline1 : headline- 1,
61
+ headline2 : headline- 2,
62
+ headline3 : headline- 3,
63
+ headline4 : headline- 4,
64
+ headline5 : headline- 5,
65
+ headline6 : headline- 6,
66
+ subtitle1 : subtitle- 1,
67
+ subtitle2 : subtitle- 2,
68
+ body1 : body- 1,
69
+ body2 : body- 2,
70
+ caption : caption ,
71
+ button : button,
72
+ overline : overline
73
+ ),
74
+ // Maps from Angular Material typography levels (e.g. body-1) to MDC typography levels
75
+ // (e.g. body1).
76
+ mat-to-mdc : (
77
+ headline-1 : headline1,
78
+ headline-2 : headline2,
79
+ headline-3 : headline3,
80
+ headline-4 : headline4,
81
+ headline-5 : headline5,
82
+ headline-6 : headline6,
83
+ subtitle-1 : subtitle1,
84
+ subtitle-2 : subtitle2,
85
+ body-1 : body1,
86
+ body-2 : body2,
87
+ caption : caption ,
88
+ button : button,
89
+ overline : overline
90
+ )
91
+ );
92
+
54
93
// Converts an Angular Material typography level config to an MDC one.
55
94
@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 );
95
+ $mappings : if (mat-private-typography-is-2018-config ($mat-config ),
96
+ $mat-typography-2018-level-mappings , $mat-typography-2014-level-mappings );
97
+ $mdc-level : map-get (map-get ($mappings , mat-to-mdc ), $mat-level );
57
98
58
99
@return map-merge (
59
100
if ($mdc-level ,
@@ -81,7 +122,10 @@ $mat-typography-level-mappings: (
81
122
@function mat-typography-config-to-mdc ($mat-config : mat-typography-config ()) {
82
123
$mdc-config : ();
83
124
84
- @each $mdc-level , $mat-level in map-get ($mat-typography-level-mappings , mdc-to-mat ) {
125
+ $mappings : if (mat-private-typography-is-2018-config ($mat-config ),
126
+ $mat-typography-2018-level-mappings , $mat-typography-2014-level-mappings );
127
+
128
+ @each $mdc-level , $mat-level in map-get ($mappings , mdc-to-mat ) {
85
129
$mdc-config : map-merge (
86
130
$mdc-config ,
87
131
($mdc-level : mat-typography-level-config-to-mdc ($mat-config , $mat-level )));
@@ -100,17 +144,6 @@ $mat-typography-level-mappings: (
100
144
map-get ($mdc-typography-styles , letter-spacing ));
101
145
}
102
146
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
-
114
147
// Configures MDC's global variables to reflect the given theme, applies the given styles,
115
148
// then resets the global variables to prevent unintended side effects.
116
149
/* stylelint-disable-next-line material/theme-mixin-api */
0 commit comments