Skip to content

Commit e2f5ace

Browse files
committed
fixup! refactor(material/theming): normalize config in all typography mixins
1 parent 4b61f0e commit e2f5ace

File tree

3 files changed

+21
-81
lines changed

3 files changed

+21
-81
lines changed

src/material-experimental/mdc-button/_button-theme.scss

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,7 @@ $mat-button-state-target: '.mdc-button__ripple';
254254
}
255255

256256
@mixin mat-mdc-fab-typography($config-or-theme) {
257-
$config: mat-private-typography-to-2014-config(mat-get-typography-config($config-or-theme));
258-
$config: mat-get-typography-config($config-or-theme);
257+
$config: mat-private-typography-to-2018-config(mat-get-typography-config($config-or-theme));
259258
@include mat-using-mdc-typography($config) {
260259
@include mdc-fab-without-ripple($query: $mat-typography-styles-query);
261260
}
@@ -328,8 +327,7 @@ $mat-button-state-target: '.mdc-button__ripple';
328327
}
329328

330329
@mixin mat-mdc-icon-button-typography($config-or-theme) {
331-
$config: mat-private-typography-to-2014-config(mat-get-typography-config($config-or-theme));
332-
$config: mat-get-typography-config($config-or-theme);
330+
$config: mat-private-typography-to-2018-config(mat-get-typography-config($config-or-theme));
333331
@include mat-using-mdc-typography($config) {
334332
@include mdc-icon-button-without-ripple($query: $mat-typography-styles-query);
335333
}

src/material-experimental/mdc-helpers/_mdc-helpers.scss

Lines changed: 16 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -17,84 +17,26 @@ $mat-base-styles-without-animation-query:
1717
$mat-theme-styles-query: color;
1818
$mat-typography-styles-query: typography;
1919

20-
// Mappings between Angular Material and MDC's typography levels.
21-
// TODO: delete once all MDC components have migrated to using the 2018 mappings.
22-
$mat-typography-2014-level-mappings: (
23-
mdc-to-mat: (
24-
headline1: display-4,
25-
headline2: display-3,
26-
headline3: display-2,
27-
headline4: display-1,
28-
headline5: headline,
29-
headline6: title,
30-
subtitle1: subheading-2,
31-
subtitle2: subheading-1,
32-
body1: body-2,
33-
body2: body-1,
20+
// Mappings from Angular Material's typography levels to MDC's typography levels.
21+
$mat-typography-mdc-level-mappings: (
22+
headline-1: headline1,
23+
headline-2: headline2,
24+
headline-3: headline3,
25+
headline-4: headline4,
26+
headline-5: headline5,
27+
headline-6: headline6,
28+
subtitle-1: subtitle1,
29+
subtitle-2: subtitle2,
30+
body-1: body1,
31+
body-2: body2,
3432
caption: caption,
3533
button: button,
36-
overline: null
37-
),
38-
mat-to-mdc: (
39-
display-4: headline1,
40-
display-3: headline2,
41-
display-2: headline3,
42-
display-1: headline4,
43-
headline: headline5,
44-
title: headline6,
45-
subheading-2: subtitle1,
46-
subheading-1: subtitle2,
47-
body-2: body1,
48-
body-1: body2,
49-
caption: caption,
50-
button: button,
51-
input: null
52-
)
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-
)
34+
overline: overline
9135
);
9236

9337
// Converts an Angular Material typography level config to an MDC one.
9438
@function mat-typography-level-config-to-mdc($mat-config, $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);
39+
$mdc-level: map-get($mat-typography-mdc-level-mappings, $mat-level);
9840

9941
@return map-merge(
10042
if($mdc-level,
@@ -119,13 +61,10 @@ $mat-typography-2018-level-mappings: (
11961
}
12062

12163
// Converts an Angular Material typography config to an MDC one.
122-
@function mat-typography-config-to-mdc($mat-config: mat-typography-config()) {
64+
@function mat-typography-config-to-mdc($mat-config) {
12365
$mdc-config: ();
12466

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) {
67+
@each $mat-level, $mdc-level in $mat-typography-mdc-level-mappings {
12968
$mdc-config: map-merge(
13069
$mdc-config,
13170
($mdc-level: mat-typography-level-config-to-mdc($mat-config, $mat-level)));

src/material/core/typography/_typography.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@
125125
body-2: map-get($config, body-1),
126126
button: map-get($config, button),
127127
caption: map-get($config, caption),
128+
overline: if(map-get($config, overline), map-get($config, overline),
129+
mat-typography-level(12px, 32px, 500)
130+
)
128131
);
129132
}
130133
@return $config;

0 commit comments

Comments
 (0)