Skip to content

Commit 0163ad2

Browse files
authored
feat(material-experimental/mdc-dialog): switch to new theming api (#23620) (#24521)
1 parent 2f06a67 commit 0163ad2

File tree

2 files changed

+70
-2
lines changed

2 files changed

+70
-2
lines changed

src/material-experimental/mdc-dialog/_dialog-theme.scss

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,56 @@
1+
@use 'sass:map';
12
@use '@material/dialog' as mdc-dialog;
3+
@use '@material/dialog/dialog-theme' as mdc-dialog-theme;
4+
@use '@material/theme/theme-color' as mdc-theme-color;
5+
@use '@material/typography' as mdc-typography;
26
@use '../mdc-helpers/mdc-helpers';
37
@use '../../material/core/typography/typography';
48
@use '../../material/core/theming/theming';
59

610
@mixin color($config-or-theme) {
711
$config: theming.get-color-config($config-or-theme);
12+
813
@include mdc-helpers.mat-using-mdc-theme($config) {
9-
@include mdc-dialog.core-styles($query: mdc-helpers.$mat-theme-styles-query);
14+
.mat-mdc-dialog-container {
15+
$surface: mdc-theme-color.$surface;
16+
$on-surface: mdc-theme-color.$on-surface;
17+
$text-emphasis-high: mdc-theme-color.text-emphasis(high);
18+
$text-emphasis-medium: mdc-theme-color.text-emphasis(medium);
19+
20+
@include mdc-dialog-theme.theme((
21+
container-color: $surface,
22+
container-elevation: 24,
23+
container-shadow-color: $on-surface,
24+
with-divider-divider-color: rgba($on-surface, mdc-dialog.$scroll-divider-opacity),
25+
subhead-color: rgba($on-surface, $text-emphasis-high),
26+
supporting-text-color: rgba($on-surface, $text-emphasis-medium),
27+
));
28+
}
1029
}
1130
}
1231

1332
@mixin typography($config-or-theme) {
1433
$config: typography.private-typography-to-2018-config(
1534
theming.get-typography-config($config-or-theme));
1635
@include mdc-helpers.mat-using-mdc-typography($config) {
17-
@include mdc-dialog.core-styles($query: mdc-helpers.$mat-typography-styles-query);
36+
.mat-mdc-dialog-container {
37+
$styles: mdc-typography.$styles;
38+
$headline6: map.get($styles, headline6);
39+
40+
@include mdc-dialog-theme.theme((
41+
subhead-font: map.get($headline6, font-family),
42+
subhead-line-height: map.get($styles, headline6, line-height),
43+
subhead-size: map.get($styles, headline6, font-size),
44+
subhead-weight: map.get($styles, headline6, font-weight),
45+
subhead-tracking: map.get($styles, headline6, letter-spacing),
46+
47+
supporting-text-font: map.get($styles, body1, font-family),
48+
supporting-text-line-height: map.get($styles, body1, line-height),
49+
supporting-text-size: map.get($styles, body1, font-size),
50+
supporting-text-weight: map.get($styles, body1, font-weight),
51+
supporting-text-tracking: map.get($styles, body1, letter-spacing),
52+
));
53+
}
1854
}
1955
}
2056

src/material-experimental/mdc-dialog/dialog.scss

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,33 @@
11
@use '@material/dialog' as mdc-dialog;
2+
@use '@material/dialog/dialog-theme' as mdc-dialog-theme;
23
@use '../mdc-helpers/mdc-helpers';
34
@use './mdc-dialog-structure-overrides';
45

6+
// Theme map with values for variables that will be overriden in the theme.
7+
// MDC's theming system requires non-null values for the slots to be inserted
8+
// and included as default values.
9+
$_dialog-initial-theme: (
10+
// Color
11+
container-color: white,
12+
container-elevation: 24,
13+
container-shadow-color: black,
14+
with-divider-divider-color: black,
15+
subhead-color: black,
16+
supporting-text-color: black,
17+
18+
// Typography
19+
subhead-font: 'Arial',
20+
subhead-line-height: 14px,
21+
subhead-size: 14px,
22+
subhead-weight: 500,
23+
subhead-tracking: 1px,
24+
supporting-text-font: 'Arial',
25+
supporting-text-line-height: 14px,
26+
supporting-text-size: 14px,
27+
supporting-text-weight: 500,
28+
supporting-text-tracking: 1px,
29+
);
30+
531
// Dialog content max height. This has been copied from the standard dialog
632
// and is needed to make the dialog content scrollable.
733
$mat-dialog-content-max-height: 65vh !default;
@@ -16,6 +42,12 @@ $mat-dialog-button-horizontal-margin: 8px !default;
1642
@include mdc-dialog-structure-overrides.private-dialog-structure-overrides(
1743
$mat-dialog-content-max-height);
1844

45+
// Apply the theming slots to the container using an initial set of
46+
// values that will be overridden in the theme styles.
47+
.mat-mdc-dialog-container {
48+
@include mdc-dialog-theme.theme-styles($_dialog-initial-theme);
49+
}
50+
1951
// The dialog container is focusable. We remove the default outline shown in browsers.
2052
.mat-mdc-dialog-container {
2153
outline: 0;

0 commit comments

Comments
 (0)