|
1 | | -@use 'sass:map'; |
2 | 1 | @use '@material/snackbar/snackbar' as mdc-snackbar; |
3 | 2 | @use '@material/snackbar/snackbar-theme' as mdc-snackbar-theme; |
| 3 | +@use '@material/theme/custom-properties' as mdc-custom-properties; |
| 4 | +@use '../core/tokens/m2/mdc/snack-bar' as tokens-mdc-snack-bar; |
| 5 | +@use '../core/tokens/m2/mat/snack-bar' as tokens-mat-snack-bar; |
| 6 | +@use '../core/tokens/token-utils'; |
4 | 7 | @use '../core/mdc-helpers/mdc-helpers'; |
5 | 8 |
|
6 | | -@include mdc-helpers.disable-mdc-fallback-declarations { |
7 | | - // Include the styles without the animations since we |
8 | | - // reuse the same animation as the non-MDC version. |
9 | | - @include mdc-snackbar.static-styles($query: mdc-helpers.$mdc-base-styles-without-animation-query); |
10 | | -} |
11 | | - |
12 | 9 | @mixin _container-min-width { |
13 | 10 | $min-width: mdc-snackbar-theme.$min-width; |
14 | 11 | $mobile-breakpoint: mdc-snackbar-theme.$mobile-breakpoint; |
|
28 | 25 | } |
29 | 26 | } |
30 | 27 |
|
31 | | -.mat-mdc-snack-bar-container { |
32 | | - @include mdc-helpers.disable-mdc-fallback-declarations { |
| 28 | +@include mdc-custom-properties.configure($emit-fallback-values: false, $emit-fallback-vars: false) { |
| 29 | + // Include the styles without the animations since we |
| 30 | + // reuse the same animation as the non-MDC version. |
| 31 | + @include mdc-snackbar.static-styles($query: mdc-helpers.$mdc-base-styles-without-animation-query); |
| 32 | + |
| 33 | + .mat-mdc-snack-bar-container { |
33 | 34 | @include _container-min-width; |
34 | 35 | @include mdc-snackbar-theme.max-width( |
35 | 36 | mdc-snackbar-theme.$max-width, |
|
45 | 46 | // a white background behind the rounded corners, because the `border-radius` is on the |
46 | 47 | // surface element. |
47 | 48 | @include mdc-snackbar-theme.elevation(mdc-snackbar-theme.$elevation); |
48 | | - |
49 | | - @include mdc-snackbar-theme.theme-styles(map.merge(mdc-snackbar-theme.$light-theme, ( |
50 | | - container-color: inherit, |
51 | | - supporting-text-color: inherit, |
52 | | - container-shape: mdc-snackbar-theme.$shape-radius, |
53 | | - supporting-text-font: inherit, |
54 | | - supporting-text-line-height: inherit, |
55 | | - supporting-text-size: inherit, |
56 | | - supporting-text-weight: inherit, |
57 | | - |
58 | | - // Removed to match the previous appearance. |
59 | | - supporting-text-tracking: null, |
60 | | - |
61 | | - // We're not using any of these since the button styling goes through `mat-button`. |
62 | | - action-label-text-color: null, |
63 | | - action-focus-state-layer-opacity: null, |
64 | | - action-hover-state-layer-opacity: null, |
65 | | - action-pressed-state-layer-opacity: null, |
66 | | - icon-focus-state-layer-opacity: null, |
67 | | - icon-hover-state-layer-opacity: null, |
68 | | - icon-pressed-state-layer-opacity: null, |
69 | | - ))); |
70 | | - } |
71 | | - |
72 | | - // MDC sets the position as fixed and sets the container on the bottom center of the page (or |
73 | | - // otherwise can be set to be "leading"). Our overlay handles a more advanced configuration |
74 | | - // of positions, so we'll defer logic there. |
75 | | - position: static; |
76 | | - |
77 | | - // The `mat-mdc-button` and `:not(:disabled)` here are redundant, but we need them to increase |
78 | | - // the specificity over the button styles that may bleed in from the rest of the app. |
79 | | - .mat-mdc-button.mat-mdc-snack-bar-action:not(:disabled) { |
80 | | - // MDC's `action-label-text-color` should be able to do this, but the button theme has a |
81 | | - // higher specificity so it ends up overriding it. Define our own variable that we can |
82 | | - // use to control the color instead. |
83 | | - color: var(--mat-mdc-snack-bar-button-color, transparent); |
84 | | - |
85 | | - // Darken the ripples in the button so they're visible against the dark background. |
86 | | - --mat-mdc-button-persistent-ripple-color: currentColor; |
87 | | - |
88 | | - .mat-ripple-element { |
89 | | - background-color: currentColor; |
90 | | - opacity: 0.1; |
| 49 | + @include mdc-snackbar-theme.theme-styles(tokens-mdc-snack-bar.get-token-slots()); |
| 50 | + @include mdc-snackbar-theme.theme(tokens-mdc-snack-bar.get-unthemable-tokens()); |
| 51 | + |
| 52 | + // MDC sets the position as fixed and sets the container on the bottom center of the page (or |
| 53 | + // otherwise can be set to be "leading"). Our overlay handles a more advanced configuration |
| 54 | + // of positions, so we'll defer logic there. |
| 55 | + position: static; |
| 56 | + |
| 57 | + // The `mat-mdc-button` and `:not(:disabled)` here are redundant, but we need them to increase |
| 58 | + // the specificity over the button styles that may bleed in from the rest of the app. |
| 59 | + .mat-mdc-button.mat-mdc-snack-bar-action:not(:disabled) { |
| 60 | + // MDC's `action-label-text-color` should be able to do this, but the button theme has a |
| 61 | + // higher specificity so it ends up overriding it. Define our own variable that we can |
| 62 | + // use to control the color instead. |
| 63 | + @include token-utils.use-tokens( |
| 64 | + tokens-mat-snack-bar.$prefix, |
| 65 | + tokens-mat-snack-bar.get-token-slots() |
| 66 | + ) { |
| 67 | + @include token-utils.create-token-slot(color, button-color); |
| 68 | + } |
| 69 | + |
| 70 | + // Darken the ripples in the button so they're visible against the dark background. |
| 71 | + --mat-mdc-button-persistent-ripple-color: currentColor; |
| 72 | + |
| 73 | + .mat-ripple-element { |
| 74 | + background-color: currentColor; |
| 75 | + opacity: 0.1; |
| 76 | + } |
91 | 77 | } |
92 | | - } |
93 | 78 |
|
94 | | - // MDC uses this pseudo element to work around an issue with their live announcer, but it |
95 | | - // can cause additional space for long snack bar messages (see #26685). Since we don't use |
96 | | - // MDC's announcer, we can hide the element. |
97 | | - .mdc-snackbar__label::before { |
98 | | - display: none; |
| 79 | + // MDC uses this pseudo element to work around an issue with their live announcer, but it |
| 80 | + // can cause additional space for long snack bar messages (see #26685). Since we don't use |
| 81 | + // MDC's announcer, we can hide the element. |
| 82 | + .mdc-snackbar__label::before { |
| 83 | + display: none; |
| 84 | + } |
99 | 85 | } |
100 | 86 | } |
101 | 87 |
|
|
0 commit comments