Skip to content

Commit 4424c0b

Browse files
committed
feat(material-experimental/theming): add M3 dialog support (#28163)
(cherry picked from commit 7a1cd42)
1 parent 4675fd9 commit 4424c0b

File tree

4 files changed

+57
-17
lines changed

4 files changed

+57
-17
lines changed

src/dev-app/theme-m3.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ $dark-theme: matx.define-theme(map.set($m3-base-config, color, theme-type, dark)
3838
html {
3939
@include mat.card-theme($light-theme);
4040
@include mat.checkbox-theme($light-theme);
41+
@include mat.dialog-theme($light-theme);
4142
@include mat.divider-theme($light-theme);
4243
@include mat.form-field-theme($light-theme);
4344
@include mat.grid-list-theme($light-theme);
@@ -73,6 +74,7 @@ html {
7374

7475
@include mat.card-color($dark-theme);
7576
@include mat.checkbox-color($dark-theme);
77+
@include mat.dialog-color($dark-theme);
7678
@include mat.divider-color($dark-theme);
7779
@include mat.form-field-color($dark-theme);
7880
@include mat.grid-list-color($dark-theme);
@@ -107,6 +109,7 @@ html {
107109
.demo-density-#{$scale} {
108110
@include mat.card-density($scale-theme);
109111
@include mat.checkbox-density($scale-theme);
112+
@include mat.dialog-density($scale-theme);
110113
@include mat.divider-density($scale-theme);
111114
@include mat.form-field-density($scale-theme);
112115
@include mat.grid-list-density($scale-theme);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ $_density-tokens: (
2020
state-layer-size: (40px, 36px, 32px, 28px),
2121
),
2222
(mdc, circular-progress): (),
23+
(mdc, dialog): (),
2324
(mdc, elevated-card): (),
2425
(mdc, filled-text-field): (),
2526
(mdc, linear-progress): (),

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@
182182
mdc-tokens.md-comp-circular-progress-indicator-values($systems, $exclude-hardcoded),
183183
$token-slots
184184
),
185+
_namespace-tokens(
186+
(mdc, dialog),
187+
mdc-tokens.md-comp-dialog-values($systems, $exclude-hardcoded),
188+
$token-slots
189+
),
185190
_namespace-tokens(
186191
(mdc, elevated-card),
187192
mdc-tokens.md-comp-elevated-card-values($systems, $exclude-hardcoded),
Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,74 @@
1+
@use 'sass:map';
12
@use '@material/dialog/dialog-theme' as mdc-dialog-theme;
23
@use '../core/style/sass-utils';
34
@use '../core/tokens/m2/mdc/dialog' as tokens-mdc-dialog;
45
@use '../core/theming/theming';
56
@use '../core/theming/inspection';
67
@use '../core/typography/typography';
78

8-
99
@mixin base($theme) {
10-
// Add default values for tokens not related to color, typography, or density.
11-
@include sass-utils.current-selector-or-root() {
12-
@include mdc-dialog-theme.theme(tokens-mdc-dialog.get-unthemable-tokens());
10+
@if inspection.get-theme-version($theme) == 1 {
11+
@include _theme-from-tokens(inspection.get-theme-tokens($theme, base));
12+
}
13+
@else {
14+
// Add default values for tokens not related to color, typography, or density.
15+
@include sass-utils.current-selector-or-root() {
16+
@include mdc-dialog-theme.theme(tokens-mdc-dialog.get-unthemable-tokens());
17+
}
1318
}
1419
}
1520

1621
@mixin color($theme) {
17-
@include sass-utils.current-selector-or-root() {
18-
@include mdc-dialog-theme.theme(tokens-mdc-dialog.get-color-tokens($theme));
22+
@if inspection.get-theme-version($theme) == 1 {
23+
@include _theme-from-tokens(inspection.get-theme-tokens($theme, color));
24+
}
25+
@else {
26+
@include sass-utils.current-selector-or-root() {
27+
@include mdc-dialog-theme.theme(tokens-mdc-dialog.get-color-tokens($theme));
28+
}
1929
}
2030
}
2131

2232
@mixin typography($theme) {
23-
@include sass-utils.current-selector-or-root() {
24-
@include mdc-dialog-theme.theme(tokens-mdc-dialog.get-typography-tokens($theme));
33+
@if inspection.get-theme-version($theme) == 1 {
34+
@include _theme-from-tokens(inspection.get-theme-tokens($theme, typography));
35+
}
36+
@else {
37+
@include sass-utils.current-selector-or-root() {
38+
@include mdc-dialog-theme.theme(tokens-mdc-dialog.get-typography-tokens($theme));
39+
}
2540
}
2641
}
2742

28-
@mixin density($theme) {}
43+
@mixin density($theme) {
44+
@if inspection.get-theme-version($theme) == 1 {
45+
@include _theme-from-tokens(inspection.get-theme-tokens($theme, density));
46+
}
47+
@else {}
48+
}
2949

3050
@mixin theme($theme) {
3151
@include theming.private-check-duplicate-theme-styles($theme, 'mat-dialog') {
32-
@include base($theme);
33-
@if inspection.theme-has($theme, color) {
34-
@include color($theme);
35-
}
36-
@if inspection.theme-has($theme, density) {
37-
@include density($theme);
52+
@if inspection.get-theme-version($theme) == 1 {
53+
@include _theme-from-tokens(inspection.get-theme-tokens($theme));
3854
}
39-
@if inspection.theme-has($theme, typography) {
40-
@include typography($theme);
55+
@else {
56+
@include base($theme);
57+
@if inspection.theme-has($theme, color) {
58+
@include color($theme);
59+
}
60+
@if inspection.theme-has($theme, density) {
61+
@include density($theme);
62+
}
63+
@if inspection.theme-has($theme, typography) {
64+
@include typography($theme);
65+
}
4166
}
4267
}
4368
}
69+
70+
@mixin _theme-from-tokens($tokens) {
71+
@if ($tokens != ()) {
72+
@include mdc-dialog-theme.theme(map.get($tokens, tokens-mdc-dialog.$prefix));
73+
}
74+
}

0 commit comments

Comments
 (0)