Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(material-experimental/theming): add M3 dialog support #28163

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/dev-app/theme-m3.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ $dark-theme: matx.define-theme(map.set($m3-base-config, color, theme-type, dark)
html {
@include mat.card-theme($light-theme);
@include mat.checkbox-theme($light-theme);
@include mat.dialog-theme($light-theme);
@include mat.divider-theme($light-theme);
@include mat.fab-theme($light-theme);
@include mat.form-field-theme($light-theme);
Expand Down Expand Up @@ -75,6 +76,7 @@ html {

@include mat.card-color($dark-theme);
@include mat.checkbox-color($dark-theme);
@include mat.dialog-color($dark-theme);
@include mat.divider-color($dark-theme);
@include mat.fab-color($dark-theme);
@include mat.form-field-color($dark-theme);
Expand Down Expand Up @@ -111,6 +113,7 @@ html {
.demo-density-#{$scale} {
@include mat.card-density($scale-theme);
@include mat.checkbox-density($scale-theme);
@include mat.dialog-density($scale-theme);
@include mat.divider-density($scale-theme);
@include mat.fab-density($scale-theme);
@include mat.form-field-density($scale-theme);
Expand Down
1 change: 1 addition & 0 deletions src/material-experimental/theming/_m3-density.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ $_density-tokens: (
state-layer-size: (40px, 36px, 32px, 28px),
),
(mdc, circular-progress): (),
(mdc, dialog): (),
(mdc, elevated-card): (),
(mdc, extended-fab): (),
(mdc, fab): (),
Expand Down
5 changes: 5 additions & 0 deletions src/material-experimental/theming/_m3-tokens.scss
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@
mdc-tokens.md-comp-circular-progress-indicator-values($systems, $exclude-hardcoded),
$token-slots
),
_namespace-tokens(
(mdc, dialog),
mdc-tokens.md-comp-dialog-values($systems, $exclude-hardcoded),
$token-slots
),
_namespace-tokens(
(mdc, elevated-card),
mdc-tokens.md-comp-elevated-card-values($systems, $exclude-hardcoded),
Expand Down
65 changes: 48 additions & 17 deletions src/material/dialog/_dialog-theme.scss
Original file line number Diff line number Diff line change
@@ -1,43 +1,74 @@
@use 'sass:map';
@use '@material/dialog/dialog-theme' as mdc-dialog-theme;
@use '../core/style/sass-utils';
@use '../core/tokens/m2/mdc/dialog' as tokens-mdc-dialog;
@use '../core/theming/theming';
@use '../core/theming/inspection';
@use '../core/typography/typography';


@mixin base($theme) {
// Add default values for tokens not related to color, typography, or density.
@include sass-utils.current-selector-or-root() {
@include mdc-dialog-theme.theme(tokens-mdc-dialog.get-unthemable-tokens());
@if inspection.get-theme-version($theme) == 1 {
@include _theme-from-tokens(inspection.get-theme-tokens($theme, base));
}
@else {
// Add default values for tokens not related to color, typography, or density.
@include sass-utils.current-selector-or-root() {
@include mdc-dialog-theme.theme(tokens-mdc-dialog.get-unthemable-tokens());
}
}
}

@mixin color($theme) {
@include sass-utils.current-selector-or-root() {
@include mdc-dialog-theme.theme(tokens-mdc-dialog.get-color-tokens($theme));
@if inspection.get-theme-version($theme) == 1 {
@include _theme-from-tokens(inspection.get-theme-tokens($theme, color));
}
@else {
@include sass-utils.current-selector-or-root() {
@include mdc-dialog-theme.theme(tokens-mdc-dialog.get-color-tokens($theme));
}
}
}

@mixin typography($theme) {
@include sass-utils.current-selector-or-root() {
@include mdc-dialog-theme.theme(tokens-mdc-dialog.get-typography-tokens($theme));
@if inspection.get-theme-version($theme) == 1 {
@include _theme-from-tokens(inspection.get-theme-tokens($theme, typography));
}
@else {
@include sass-utils.current-selector-or-root() {
@include mdc-dialog-theme.theme(tokens-mdc-dialog.get-typography-tokens($theme));
}
}
}

@mixin density($theme) {}
@mixin density($theme) {
@if inspection.get-theme-version($theme) == 1 {
@include _theme-from-tokens(inspection.get-theme-tokens($theme, density));
}
@else {}
}

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-dialog') {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
@if inspection.theme-has($theme, density) {
@include density($theme);
@if inspection.get-theme-version($theme) == 1 {
@include _theme-from-tokens(inspection.get-theme-tokens($theme));
}
@if inspection.theme-has($theme, typography) {
@include typography($theme);
@else {
@include base($theme);
@if inspection.theme-has($theme, color) {
@include color($theme);
}
@if inspection.theme-has($theme, density) {
@include density($theme);
}
@if inspection.theme-has($theme, typography) {
@include typography($theme);
}
}
}
}

@mixin _theme-from-tokens($tokens) {
@if ($tokens != ()) {
@include mdc-dialog-theme.theme(map.get($tokens, tokens-mdc-dialog.$prefix));
}
}
Loading