|
| 1 | +@use 'sass:map'; |
1 | 2 | @use '@angular/material' as mat;
|
2 | 3 | @use '@angular/cdk';
|
3 |
| -@use '@material/snackbar' as mdc-snackbar; |
| 4 | +@use '@material/snackbar/snackbar' as mdc-snackbar; |
| 5 | +@use '@material/snackbar/snackbar-theme' as mdc-snackbar-theme; |
4 | 6 |
|
5 | 7 |
|
6 | 8 | @include mat.private-disable-mdc-fallback-declarations {
|
7 | 9 | // Include the styles without the animations since we
|
8 | 10 | // reuse the same animation as the non-MDC version.
|
9 |
| - @include mdc-snackbar.core-styles($query: mat.$private-mdc-base-styles-without-animation-query); |
| 11 | + @include mdc-snackbar.static-styles($query: mat.$private-mdc-base-styles-without-animation-query); |
10 | 12 | }
|
11 | 13 |
|
12 |
| -// MDC sets the position as fixed and sets the container on the bottom center of the page (or |
13 |
| -// otherwise can be set to be "leading"). Our overlay handles a more advanced configuration |
14 |
| -// of positions, so we'll defer logic there. |
15 | 14 | .mat-mdc-snack-bar-container {
|
| 15 | + @include mat.private-disable-mdc-fallback-declarations { |
| 16 | + // The styles weren't included in `static-styles` so we need to add them ourselves. |
| 17 | + @include mdc-snackbar-theme.min-width( |
| 18 | + mdc-snackbar-theme.$min-width, |
| 19 | + $query: mat.$private-mdc-base-styles-query |
| 20 | + ); |
| 21 | + @include mdc-snackbar-theme.max-width( |
| 22 | + mdc-snackbar-theme.$max-width, |
| 23 | + $query: mat.$private-mdc-base-styles-query |
| 24 | + ); |
| 25 | + @include mdc-snackbar-theme.viewport-margin( |
| 26 | + mdc-snackbar-theme.$viewport-margin-narrow, |
| 27 | + $query: mat.$private-mdc-base-styles-query |
| 28 | + ); |
| 29 | + |
| 30 | + // MDC has the `container-elevation` which sounds like it should work, but it ends up applying |
| 31 | + // the shadow on the outer container instead of the `.mdc-snackbar__surface` which causes |
| 32 | + // a white background behind the rounded corners, because the `border-radius` is on the |
| 33 | + // surface element. |
| 34 | + @include mdc-snackbar-theme.elevation(mdc-snackbar-theme.$elevation); |
| 35 | + |
| 36 | + @include mdc-snackbar-theme.theme-styles(map.merge(mdc-snackbar-theme.$light-theme, ( |
| 37 | + container-color: inherit, |
| 38 | + supporting-text-color: inherit, |
| 39 | + container-shape: mdc-snackbar-theme.$shape-radius, |
| 40 | + supporting-text-font: inherit, |
| 41 | + supporting-text-line-height: inherit, |
| 42 | + supporting-text-size: inherit, |
| 43 | + supporting-text-weight: inherit, |
| 44 | + |
| 45 | + // Removed to match the previous appearance. |
| 46 | + supporting-text-tracking: null, |
| 47 | + |
| 48 | + // We're not using any of these since the button styling goes through `mat-button`. |
| 49 | + action-label-text-color: null, |
| 50 | + action-focus-state-layer-opacity: null, |
| 51 | + action-hover-state-layer-opacity: null, |
| 52 | + action-pressed-state-layer-opacity: null, |
| 53 | + icon-focus-state-layer-opacity: null, |
| 54 | + icon-hover-state-layer-opacity: null, |
| 55 | + icon-pressed-state-layer-opacity: null, |
| 56 | + ))); |
| 57 | + } |
| 58 | + |
| 59 | + // MDC sets the position as fixed and sets the container on the bottom center of the page (or |
| 60 | + // otherwise can be set to be "leading"). Our overlay handles a more advanced configuration |
| 61 | + // of positions, so we'll defer logic there. |
16 | 62 | position: static;
|
17 | 63 |
|
18 | 64 | @include cdk.high-contrast(active, off) {
|
19 | 65 | border: solid 1px;
|
20 | 66 | }
|
| 67 | + |
| 68 | + // The `mat-mdc-button` and `:not(:disabled)` here are redundant, but we need them to increase |
| 69 | + // the specificity over the button styles that may bleed in from the rest of the app. |
| 70 | + .mat-mdc-button.mat-mdc-snack-bar-action:not(:disabled) { |
| 71 | + // MDC's `action-label-text-color` should be able to do this, but the button theme has a |
| 72 | + // higher specificity so it ends up overriding it. Define our own variable that we can |
| 73 | + // use to control the color instead. |
| 74 | + color: var(--mat-mdc-snack-bar-button-color, transparent); |
| 75 | + |
| 76 | + // Darken the ripples in the button so they're visible against the dark background. |
| 77 | + --mat-mdc-button-persistent-ripple-color: currentColor; |
| 78 | + |
| 79 | + .mat-ripple-element { |
| 80 | + background-color: currentColor; |
| 81 | + opacity: 0.1; |
| 82 | + } |
| 83 | + } |
21 | 84 | }
|
22 | 85 |
|
23 | 86 | // These elements need to have full width using flex layout.
|
|
0 commit comments