I want to add the Colored snackbars component. However, I get the following error when compiling:
Error: There's already a module with namespace "color-palette".\n
My SCSS file is the same as in the documentation Theming. I simply added the Snackbar SCSS:
@use '@material/theme/color-palette';
$background: #fff;
@use '@material/theme/index' as theme with (
$primary: color-palette.$purple-500,
$secondary: color-palette.$teal-600,
$surface: #fff,
$background: $background,
$error: #b00020
);
// See https://github.com/material-components/material-components-web/tree/v14.0.0/packages/mdc-snackbar
@use '@material/snackbar/mixins';
// See https://github.com/material-components/material-components-web/tree/v14.0.0/packages/mdc-theme
@use '@material/theme/color-palette';
@use '@material/theme/theme-color';
.mdc-snackbar.demo-success {
@include mixins.fill-color(color-palette.$green-500);
@include mixins.label-ink-color(
theme-color.accessible-ink-color(color-palette.$green-500)
);
}
.mdc-snackbar.demo-warning {
@include mixins.fill-color(color-palette.$orange-500);
@include mixins.label-ink-color(
theme-color.accessible-ink-color(color-palette.$orange-500)
);
}
.mdc-snackbar.demo-error {
@include mixins.fill-color(color-palette.$red-500);
@include mixins.label-ink-color(
theme-color.accessible-ink-color(color-palette.$red-500)
);
}
html,
body {
background-color: $background;
color: if(theme.contrast-tone($background) == 'dark', #000, #fff);
}
a {
color: color-palette.$blue-500;
}
a:visited {
color: color-palette.$blue-800;
}
what you wanna do is create a new file called
myStyle.scss
.This is the example from the SMUI Docs but with
@use "@smui/snackbar/style";
prepended.You can then
@use
that file over in your_smui-theme.scss
like this.