Closed varghesethomase closed 1 year ago
Here's my workaround that bypasses the nice Snackbar mixins and just hardcodes the colours:
.mdc-snackbar.snackbar--success .mdc-snackbar__surface {
background-color: color-palette.$green-500;
}
.mdc-snackbar.snackbar--success .mdc-snackbar__surface .mdc-snackbar__label,
.mdc-snackbar.snackbar--success .mdc-snackbar__surface .mdc-snackbar__actions .mdc-snackbar__dismiss {
color: black;
}
.mdc-snackbar.snackbar--warning .mdc-snackbar__surface {
background-color: color-palette.$orange-500;
}
.mdc-snackbar.snackbar--warning .mdc-snackbar__surface .mdc-snackbar__label,
.mdc-snackbar.snackbar--warning .mdc-snackbar__surface .mdc-snackbar__actions .mdc-snackbar__dismiss {
color: black;
}
.mdc-snackbar.snackbar--error .mdc-snackbar__surface {
background-color: color-palette.$red-500;
}
.mdc-snackbar.snackbar--error .mdc-snackbar__surface .mdc-snackbar__label,
.mdc-snackbar.snackbar--error .mdc-snackbar__surface .mdc-snackbar__actions .mdc-snackbar__dismiss {
color: white;
}
The problem is the import order of Sass. You need to make sure that your custom color import comes after the default SMUI imports. You can do this by adding this line before your custom color code:
@use '@smui/snackbar/style' as smui-snackabar;
So your file would look like this:
@use '@smui/snackbar/style' as smui-snackabar;
@use '@material/snackbar/index' as snackabar;
.mdc-snackbar.snackbar--success {
@include snackabar.fill-color(color-palette.$green-900);
@include snackabar.label-ink-color(theme.accessible-ink-color(color-palette.$green-900));
}
.mdc-snackbar.snackbar--warning {
@include snackabar.fill-color(color-palette.$orange-900);
@include snackabar.label-ink-color(theme.accessible-ink-color(color-palette.$orange-900));
}
.mdc-snackbar.snackbar--error {
@include snackabar.fill-color(color-palette.$red-900);
@include snackabar.label-ink-color(theme.accessible-ink-color(color-palette.$red-900));
}
The ensures that SMUI's import happens first.
This is definitely an issue with my documentation though, so it should be fixed.
Describe the bug As multiple people face the same issue as shown in the stack overflow thread, it seems like the example given here on how to have multiple variants of the snackbar eg: success, error and warning is broken. As shown in the figure below, on trying to compile sass, it errors.
To Reproduce Steps to reproduce the behavior:
.mdc-snackbar.snackbar--success { @include snackabar.fill-color(color-palette.$green-900); @include snackabar.label-ink-color(theme.accessible-ink-color(color-palette.$green-900)); }
.mdc-snackbar.snackbar--warning { @include snackabar.fill-color(color-palette.$orange-900); @include snackabar.label-ink-color(theme.accessible-ink-color(color-palette.$orange-900)); }
.mdc-snackbar.snackbar--error { @include snackabar.fill-color(color-palette.$red-900); @include snackabar.label-ink-color(theme.accessible-ink-color(color-palette.$red-900)); }