Skip to content

Commit f67c871

Browse files
authored
feat(material-experimental/theming): add M3 grid-list support (#28131)
1 parent 178c945 commit f67c871

File tree

6 files changed

+71
-14
lines changed

6 files changed

+71
-14
lines changed

src/dev-app/theme-m3.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ html {
3939
@include mat.card-theme($light-theme);
4040
@include mat.checkbox-theme($light-theme);
4141
@include mat.form-field-theme($light-theme);
42+
@include mat.grid-list-theme($light-theme);
4243
@include mat.input-theme($light-theme);
4344
@include mat.list-theme($light-theme);
4445
@include mat.progress-bar-theme($light-theme);
@@ -66,6 +67,7 @@ html {
6667
@include mat.card-color($dark-theme);
6768
@include mat.checkbox-color($dark-theme);
6869
@include mat.form-field-color($dark-theme);
70+
@include mat.grid-list-color($dark-theme);
6971
@include mat.input-color($dark-theme);
7072
@include mat.list-color($dark-theme);
7173
@include mat.progress-bar-color($dark-theme);
@@ -92,6 +94,7 @@ html {
9294
@include mat.card-density($scale-theme);
9395
@include mat.checkbox-density($scale-theme);
9496
@include mat.form-field-density($scale-theme);
97+
@include mat.grid-list-density($scale-theme);
9598
@include mat.input-density($scale-theme);
9699
@include mat.list-density($scale-theme);
97100
@include mat.progress-bar-density($scale-theme);

src/material-experimental/theming/_custom-tokens.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@
6262
);
6363
}
6464

65+
/// Generates custom tokens for the mat-grid-list.
66+
/// @param {Map} $systems The MDC system tokens
67+
/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values
68+
/// @return {Map} A set of custom tokens for the mat-grid-list
69+
@function grid-list($systems, $exclude-hardcoded) {
70+
@return (
71+
tile-header-primary-text-size: map.get($systems, md-sys-typescale, body-large),
72+
tile-header-secondary-text-size: map.get($systems, md-sys-typescale, body-medium),
73+
tile-footer-primary-text-size: map.get($systems, md-sys-typescale, body-large),
74+
tile-footer-secondary-text-size: map.get($systems, md-sys-typescale, body-medium),
75+
);
76+
}
77+
6578
/// Generates custom tokens for the mat-toolbar.
6679
/// @param {Map} $systems The MDC system tokens
6780
/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values

src/material-experimental/theming/_m3-density.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ $_density-tokens: (
4545
// Custom Angular Material tokens
4646
(mat, card): (),
4747
(mat, form-fild): (),
48+
(mat, grid-list): (),
4849
(mat, toolbar): (
4950
standard-height: (64px, 60px, 56px, 52px),
5051
mobile-height: (56px, 52px, 48px, 44px),

src/material-experimental/theming/_m3-tokens.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@
259259
custom-tokens.form-field($systems, $exclude-hardcoded),
260260
$token-slots
261261
),
262+
_namespace-tokens(
263+
(mat, grid-list),
264+
custom-tokens.grid-list($systems, $exclude-hardcoded),
265+
$token-slots
266+
),
262267
_namespace-tokens(
263268
(mat, toolbar),
264269
custom-tokens.toolbar($systems, $exclude-hardcoded),

src/material/core/tokens/m2/_index.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@use '../../style/sass-utils';
44
@use './mat/card' as tokens-mat-card;
55
@use './mat/form-field' as tokens-mat-form-field;
6+
@use './mat/grid-list' as tokens-mat-grid-list;
67
@use './mat/radio' as tokens-mat-radio;
78
@use './mat/ripple' as tokens-mat-ripple;
89
@use './mat/slide-toggle' as tokens-mat-slide-toggle;
@@ -78,6 +79,7 @@
7879
@return sass-utils.deep-merge-all(
7980
_get-tokens-for-module($theme, tokens-mat-card),
8081
_get-tokens-for-module($theme, tokens-mat-form-field),
82+
_get-tokens-for-module($theme, tokens-mat-grid-list),
8183
_get-tokens-for-module($theme, tokens-mat-radio),
8284
_get-tokens-for-module($theme, tokens-mat-ripple),
8385
_get-tokens-for-module($theme, tokens-mat-slide-toggle),
Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,68 @@
1+
@use 'sass:map';
12
@use '../core/theming/theming';
23
@use '../core/theming/inspection';
34
@use '../core/typography/typography';
45
@use '../core/tokens/m2/mat/grid-list' as tokens-mat-grid-list;
56
@use '../core/style/sass-utils';
67
@use '../core/tokens/token-utils';
78

8-
@mixin base($theme) {}
9+
@mixin base($theme) {
10+
@if inspection.get-theme-version($theme) == 1 {
11+
@include _theme-from-tokens(inspection.get-theme-tokens($theme, base));
12+
}
13+
@else {}
14+
}
915

1016
// Include this empty mixin for consistency with the other components.
11-
@mixin color($theme) {}
17+
@mixin color($theme) {
18+
@if inspection.get-theme-version($theme) == 1 {
19+
@include _theme-from-tokens(inspection.get-theme-tokens($theme, color));
20+
}
21+
@else {}
22+
}
1223

1324
@mixin typography($theme) {
14-
@include sass-utils.current-selector-or-root() {
15-
@include token-utils.create-token-values(tokens-mat-grid-list.$prefix,
16-
tokens-mat-grid-list.get-typography-tokens($theme));
25+
@if inspection.get-theme-version($theme) == 1 {
26+
@include _theme-from-tokens(inspection.get-theme-tokens($theme, typography));
27+
}
28+
@else {
29+
@include sass-utils.current-selector-or-root() {
30+
@include token-utils.create-token-values(tokens-mat-grid-list.$prefix,
31+
tokens-mat-grid-list.get-typography-tokens($theme));
32+
}
1733
}
1834
}
1935

20-
@mixin density($theme) {}
36+
@mixin density($theme) {
37+
@if inspection.get-theme-version($theme) == 1 {
38+
@include _theme-from-tokens(inspection.get-theme-tokens($theme, density));
39+
}
40+
@else {}
41+
}
2142

2243
@mixin theme($theme) {
2344
@include theming.private-check-duplicate-theme-styles($theme, 'mat-grid-list') {
24-
@include base($theme);
25-
@if inspection.theme-has($theme, color) {
26-
@include color($theme);
27-
}
28-
@if inspection.theme-has($theme, density) {
29-
@include density($theme);
45+
@if inspection.get-theme-version($theme) == 1 {
46+
@include _theme-from-tokens(inspection.get-theme-tokens($theme));
3047
}
31-
@if inspection.theme-has($theme, typography) {
32-
@include typography($theme);
48+
@else {
49+
@include base($theme);
50+
@if inspection.theme-has($theme, color) {
51+
@include color($theme);
52+
}
53+
@if inspection.theme-has($theme, density) {
54+
@include density($theme);
55+
}
56+
@if inspection.theme-has($theme, typography) {
57+
@include typography($theme);
58+
}
3359
}
3460
}
3561
}
62+
63+
@mixin _theme-from-tokens($tokens) {
64+
@if ($tokens != ()) {
65+
@include token-utils.create-token-values(
66+
tokens-mat-grid-list.$prefix, map.get($tokens, tokens-mat-grid-list.$prefix));
67+
}
68+
}

0 commit comments

Comments
 (0)