@@ -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,45 @@ $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
+ 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
+
54
89
// Converts an Angular Material typography level config to an MDC one.
55
90
@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 );
57
94
58
95
@return map-merge (
59
96
if ($mdc-level ,
@@ -81,7 +118,10 @@ $mat-typography-level-mappings: (
81
118
@function mat-typography-config-to-mdc ($mat-config : mat-typography-config ()) {
82
119
$mdc-config : ();
83
120
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 ) {
85
125
$mdc-config : map-merge (
86
126
$mdc-config ,
87
127
($mdc-level : mat-typography-level-config-to-mdc ($mat-config , $mat-level )));
@@ -100,17 +140,6 @@ $mat-typography-level-mappings: (
100
140
map-get ($mdc-typography-styles , letter-spacing ));
101
141
}
102
142
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
143
// Configures MDC's global variables to reflect the given theme, applies the given styles,
115
144
// then resets the global variables to prevent unintended side effects.
116
145
/* stylelint-disable-next-line material/theme-mixin-api */
0 commit comments