Skip to content

refactor(material/dialog): simplify structural styles #29068

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

Merged
merged 1 commit into from
May 21, 2024
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
2 changes: 2 additions & 0 deletions src/material/core/tokens/m2/mat/_dialog.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@use '@material/elevation/elevation-theme' as mdc-elevation;
@use '../../token-utils';
@use '../../../style/sass-utils';

Expand All @@ -8,6 +9,7 @@ $prefix: (mat, dialog);
// but may be in a future version of the theming API.
@function get-unthemable-tokens() {
@return (
container-elevation-shadow: mdc-elevation.elevation-box-shadow(24),
container-max-width: 80vw,
container-small-max-width: 80vw,
container-min-width: 0,
Expand Down
6 changes: 2 additions & 4 deletions src/material/core/tokens/m2/mdc/_dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ $prefix: (mdc, dialog);
// our CSS.
@function get-unthemable-tokens() {
@return (
// Height of the container's elevation.
container-elevation: 24,
// Color of the elevation shadow.
container-shadow-color: #000,
// Border radius of the container.
container-shape: 4px,
// =============================================================================================
// = TOKENS NOT USED IN ANGULAR MATERIAL =
// =============================================================================================
container-elevation: null,
container-shadow-color: null,
with-divider-divider-height: null,
with-divider-divider-color: null,
with-icon-icon-size: null,
Expand Down
1 change: 1 addition & 0 deletions src/material/core/tokens/m3/mat/_dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ $prefix: (mat, dialog);
/// @return {Map} A set of custom tokens for the dialog
@function get-tokens($systems, $exclude-hardcoded, $token-slots) {
$tokens: (
container-elevation-shadow: token-utils.hardcode(none, $exclude-hardcoded),
container-max-width: token-utils.hardcode(560px, $exclude-hardcoded),
container-small-max-width: token-utils.hardcode(calc(100vw - 32px), $exclude-hardcoded),
container-min-width: token-utils.hardcode(280px, $exclude-hardcoded),
Expand Down
16 changes: 0 additions & 16 deletions src/material/core/tokens/m3/mdc/_dialog.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@use 'sass:map';
@use '../../token-utils';

// The prefix used to generate the fully qualified name for tokens in this file.
Expand All @@ -20,20 +19,5 @@ $prefix: (mdc, dialog);
headline-weight: subhead-weight,
));

@if map.get($tokens, container-elevation) != null {
$tokens: map.merge($tokens, (
// The spec has the dialog at an elevation of 3 which is consistent with the current
// version of the tokens (0_161), however both the designs and MDC's implementation
// have the elevation set to 0. Set it manually to 0 here since the value in the
// exported tokens is likely outdated.
container-elevation: 0,

// This color needs to be supplied for MDC to produce the shadow. Technically we don't
// have to provide it since the elevation is set to 0 above, but we do it in case
// the value changes in the future.
container-shadow-color: #000,
));
}

@return token-utils.namespace-tokens($prefix, $tokens, $token-slots);
}
13 changes: 8 additions & 5 deletions src/material/dialog/_dialog-theme.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@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/tokens/m2/mat/dialog' as tokens-mat-dialog;
Expand All @@ -16,7 +15,8 @@
@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());
@include token-utils.create-token-values(
tokens-mdc-dialog.$prefix, tokens-mdc-dialog.get-unthemable-tokens());
@include token-utils.create-token-values(
tokens-mat-dialog.$prefix, tokens-mat-dialog.get-unthemable-tokens());
}
Expand All @@ -29,7 +29,8 @@
}
@else {
@include sass-utils.current-selector-or-root() {
@include mdc-dialog-theme.theme(tokens-mdc-dialog.get-color-tokens($theme));
@include token-utils.create-token-values(
tokens-mdc-dialog.$prefix, tokens-mdc-dialog.get-color-tokens($theme));
@include token-utils.create-token-values(
tokens-mat-dialog.$prefix, tokens-mat-dialog.get-color-tokens($theme));
}
Expand All @@ -42,7 +43,8 @@
}
@else {
@include sass-utils.current-selector-or-root() {
@include mdc-dialog-theme.theme(tokens-mdc-dialog.get-typography-tokens($theme));
@include token-utils.create-token-values(
tokens-mdc-dialog.$prefix, tokens-mdc-dialog.get-typography-tokens($theme));
@include token-utils.create-token-values(
tokens-mat-dialog.$prefix, tokens-mat-dialog.get-typography-tokens($theme));
}
Expand Down Expand Up @@ -88,7 +90,8 @@
@include validation.selector-defined(
'Calls to Angular Material theme mixins with an M3 theme must be wrapped in a selector');
@if ($tokens != ()) {
@include mdc-dialog-theme.theme(map.get($tokens, tokens-mdc-dialog.$prefix));
@include token-utils.create-token-values(
tokens-mdc-dialog.$prefix, map.get($tokens, tokens-mdc-dialog.$prefix));
@include token-utils.create-token-values(
tokens-mat-dialog.$prefix, map.get($tokens, tokens-mat-dialog.$prefix));
}
Expand Down
58 changes: 0 additions & 58 deletions src/material/dialog/_mdc-dialog-structure-overrides.scss

This file was deleted.

2 changes: 1 addition & 1 deletion src/material/dialog/dialog-container.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="mdc-dialog__container">
<div class="mat-mdc-dialog-inner-container mdc-dialog__container">
<div class="mat-mdc-dialog-surface mdc-dialog__surface">
<ng-template cdkPortalOutlet />
</div>
Expand Down
Loading
Loading