Skip to content

Commit c36426c

Browse files
author
Andrew Seguin
committed
refactor: realign changes with g3
1 parent 89d9cd0 commit c36426c

File tree

5 files changed

+54
-49
lines changed

5 files changed

+54
-49
lines changed

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

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,44 @@
33
@use 'sass:meta';
44

55
@function md-sys-typescale-values($config) {
6+
// Mapping is according to the old 2014 version of the typography spec.
67
$sys-to-config: (
7-
body-large: body-1,
8-
body-medium: body-2,
8+
body-large: subheading-1,
9+
body-medium: body-1,
910
body-small: caption,
10-
label-large: subtitle-1,
11-
label-medium: subtitle-2,
11+
display-large: display-4,
12+
display-medium: display-4,
13+
display-small: display-4,
14+
headline-large: display-3,
15+
headline-medium: display-2,
16+
headline-small: display-1,
17+
label-large: subheading-2,
18+
label-medium: body-2,
1219
label-small: button,
13-
display-large: headline-1,
14-
display-medium: headline-1,
15-
display-small: headline-1,
16-
headline-large: headline-2,
17-
headline-medium: headline-3,
18-
headline-small: headline-4,
19-
title-large: headline-5,
20-
title-medium: headline-5,
21-
title-small: headline-6,
20+
title-large: headline,
21+
title-medium: headline,
22+
title-small: title,
2223
);
2324

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) {
25+
// If the config is based on the updated 2018 version of the typography spec, then
26+
// use the correct config keys mapping.
27+
@if (map.get($config, headline-1) != null) {
2728
$sys-to-config: (
28-
body-large: subheading-1,
29-
body-medium: body-1,
29+
body-large: body-1,
30+
body-medium: body-2,
3031
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,
32+
label-large: subtitle-1,
33+
label-medium: subtitle-2,
3934
label-small: button,
40-
title-large: headline,
41-
title-medium: headline,
42-
title-small: title,
35+
display-large: headline-1,
36+
display-medium: headline-1,
37+
display-small: headline-1,
38+
headline-large: headline-2,
39+
headline-medium: headline-3,
40+
headline-small: headline-4,
41+
title-large: headline-5,
42+
title-medium: headline-5,
43+
title-small: headline-6,
4344
);
4445
}
4546

src/material/expansion/_m2-expansion.scss

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,24 @@
3737

3838
// Tokens that can be configured through Angular Material's typography theming API.
3939
@function get-typography-tokens($theme) {
40-
$system: m2-utils.get-system($theme);
4140
@return (
42-
expansion-header-text-font: map.get($system, label-medium-font),
43-
expansion-header-text-size: map.get($system, label-medium-size),
44-
expansion-header-text-weight: map.get($system, label-medium-weight),
41+
expansion-header-text-font: inspection.get-theme-typography($theme, subtitle-2, font-family),
42+
expansion-header-text-size: inspection.get-theme-typography($theme, subtitle-2, font-size),
43+
expansion-header-text-weight: inspection.get-theme-typography($theme, subtitle-2, font-weight),
4544

4645
// TODO(crisbeto): these two properties weren't set at all before the introduction of tokens,
4746
// but it's inconsistent not to provide them since the container sets all of them. Eventually
4847
// we should change the values to use come from `subtitle-2`.
4948
expansion-header-text-line-height: inherit,
5049
expansion-header-text-tracking: inherit,
5150

52-
expansion-container-text-font: map.get($system, body-medium-font),
53-
expansion-container-text-line-height: map.get($system, body-medium-line-height),
54-
expansion-container-text-size: map.get($system, body-medium-size),
55-
expansion-container-text-tracking: map.get($system, body-medium-tracking),
56-
expansion-container-text-weight: map.get($system, body-medium-weight),
51+
expansion-container-text-font: inspection.get-theme-typography($theme, body-2, font-family),
52+
expansion-container-text-line-height:
53+
inspection.get-theme-typography($theme, body-2, line-height),
54+
expansion-container-text-size: inspection.get-theme-typography($theme, body-2, font-size),
55+
expansion-container-text-tracking:
56+
inspection.get-theme-typography($theme, body-2, letter-spacing),
57+
expansion-container-text-weight: inspection.get-theme-typography($theme, body-2, font-weight),
5758
);
5859
}
5960

src/material/slide-toggle/_slide-toggle-theme.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
$system: m2-utils.get-system($theme);
4545

4646
& {
47+
// TODO(andrewjs): Remove this once all tokens are migrated to
48+
// mat internally.
49+
--mdc-slide-toggle-disabled-label-text-color: #{
50+
m3-utils.color-with-opacity(map.get($system, on-surface), 38%)};
4751
// TODO(wagnermaciel): Use our token system to define this css variable.
4852
--mat-slide-toggle-disabled-label-text-color: #{
4953
m3-utils.color-with-opacity(map.get($system, on-surface), 38%)};

src/material/toolbar/_m2-toolbar.scss

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020

2121
// Tokens that can be configured through Angular Material's typography theming API.
2222
@function get-typography-tokens($theme) {
23-
$system: m2-utils.get-system($theme);
2423
@return (
25-
toolbar-title-text-font: map.get($system, title-small-font),
26-
toolbar-title-text-line-height: map.get($system, title-small-line-height),
27-
toolbar-title-text-size: map.get($system, title-small-size),
28-
toolbar-title-text-tracking: map.get($system, title-small-tracking),
29-
toolbar-title-text-weight: map.get($system, title-small-weight),
24+
toolbar-title-text-font: inspection.get-theme-typography($theme, headline-6, font-family),
25+
toolbar-title-text-line-height:
26+
inspection.get-theme-typography($theme, headline-6, line-height),
27+
toolbar-title-text-size: inspection.get-theme-typography($theme, headline-6, font-size),
28+
toolbar-title-text-tracking:
29+
inspection.get-theme-typography($theme, headline-6, letter-spacing),
30+
toolbar-title-text-weight: inspection.get-theme-typography($theme, headline-6, font-weight),
3031
);
3132
}
32-
3333
// Tokens that can be configured through Angular Material's density theming API.
3434
@function get-density-tokens($theme) {
3535
$density-scale: theming.clamp-density(inspection.get-theme-density($theme), -3);

src/material/tree/_m2-tree.scss

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121

2222
// Tokens that can be configured through Angular Material's typography theming API.
2323
@function get-typography-tokens($theme) {
24-
$system: m2-utils.get-system($theme);
2524
@return (
26-
tree-node-text-font: map.get($system, body-medium-font),
27-
tree-node-text-size: map.get($system, body-medium-size),
28-
tree-node-text-weight: map.get($system, body-medium-weight),
25+
tree-node-text-font: inspection.get-theme-typography($theme, body-2, font-family),
26+
tree-node-text-size: inspection.get-theme-typography($theme, body-2, font-size),
27+
tree-node-text-weight: inspection.get-theme-typography($theme, body-2, font-weight),
2928

3029
// TODO(crisbeto): provide tokens for line height and letter spacing to match other components.
3130
);

0 commit comments

Comments
 (0)