Skip to content

Commit 142ef63

Browse files
committed
docs: update colored snackbar demo to use mixins and material palette
1 parent c6a6354 commit 142ef63

File tree

4 files changed

+43
-24
lines changed

4 files changed

+43
-24
lines changed
Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
1-
// Add the below to your _smui-theme.scss file
1+
// See https://github.com/material-components/material-components-web/blob/v13.0.0/packages/mdc-snackbar/
2+
@use '@material/snackbar/mixins';
3+
// See https://github.com/material-components/material-components-web/blob/v13.0.0/packages/mdc-theme/
4+
@use '@material/theme/color-palette';
5+
@use '@material/theme/theme-color';
26

3-
.success .mdc-snackbar__surface {
4-
background-color: green;
7+
.mdc-snackbar.demo-success {
8+
@include mixins.fill-color(color-palette.$green-500);
9+
@include mixins.label-ink-color(
10+
theme-color.accessible-ink-color(color-palette.$green-500)
11+
);
512
}
613

7-
.warning .mdc-snackbar__surface {
8-
background-color: orange;
14+
.mdc-snackbar.demo-warning {
15+
@include mixins.fill-color(color-palette.$orange-500);
16+
@include mixins.label-ink-color(
17+
theme-color.accessible-ink-color(color-palette.$orange-500)
18+
);
919
}
1020

11-
.error .mdc-snackbar__surface {
12-
background-color: red;
21+
.mdc-snackbar.demo-error {
22+
@include mixins.fill-color(color-palette.$red-500);
23+
@include mixins.label-ink-color(
24+
theme-color.accessible-ink-color(color-palette.$red-500)
25+
);
1326
}
Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,50 @@
1-
<Snackbar bind:this={snackbarSuccess} class="success">
2-
<Label>{snackbarText}</Label>
1+
<Snackbar bind:this={snackbarSuccess} class="demo-success">
2+
<Label
3+
>That thing you tried to do actually worked, if you can believe it!</Label
4+
>
35
<Actions>
46
<IconButton class="material-icons" title="Dismiss">close</IconButton>
57
</Actions>
68
</Snackbar>
79

8-
<Snackbar bind:this={snackbarWarning} class="warning">
9-
<Label>{snackbarText}</Label>
10+
<Snackbar bind:this={snackbarWarning} class="demo-warning">
11+
<Label
12+
>Ok, it looks like that thing you tried to do might not have work.</Label
13+
>
1014
<Actions>
1115
<IconButton class="material-icons" title="Dismiss">close</IconButton>
1216
</Actions>
1317
</Snackbar>
1418

15-
<Snackbar bind:this={snackbarError} class="error">
16-
<Label>{snackbarText}</Label>
19+
<Snackbar bind:this={snackbarError} class="demo-error">
20+
<Label
21+
>That thing you tried to do didn't work. Honestly, I'm not sure why you even
22+
tried.</Label
23+
>
1724
<Actions>
1825
<IconButton class="material-icons" title="Dismiss">close</IconButton>
1926
</Actions>
2027
</Snackbar>
2128

2229
<Button on:click={() => snackbarSuccess && snackbarSuccess.open()}>
23-
<Label style="color:green">Open Snackbar Success</Label>
30+
<Label>Open Success Snackbar</Label>
2431
</Button>
2532

2633
<Button on:click={() => snackbarWarning && snackbarWarning.open()}>
27-
<Label style="color:orange">Open Snackbar Warning</Label>
34+
<Label>Open Warning Snackbar</Label>
2835
</Button>
2936

3037
<Button on:click={() => snackbarError && snackbarError.open()}>
31-
<Label style="color:red">Open Snackbar Error</Label>
38+
<Label>Open Error Snackbar</Label>
3239
</Button>
3340

3441
<script lang="ts">
35-
import Snackbar, {
36-
Label,
37-
Actions,
38-
SnackbarComponentDev,
39-
} from '@smui/snackbar';
42+
import type { SnackbarComponentDev } from '@smui/snackbar';
43+
import Snackbar, { Label, Actions } from '@smui/snackbar';
4044
import IconButton from '@smui/icon-button';
4145
import Button from '@smui/button';
4246
4347
let snackbarSuccess: SnackbarComponentDev;
4448
let snackbarWarning: SnackbarComponentDev;
4549
let snackbarError: SnackbarComponentDev;
46-
47-
let snackbarText = 'Snackbar Text';
4850
</script>

packages/site/src/routes/demo/snackbar/index.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
Using dynamic text
2626
</Demo>
2727

28-
<Demo component={Colors} file="snackbar/_Colors.svelte">
28+
<Demo
29+
component={Colors}
30+
files={['snackbar/_Colors.svelte', 'snackbar/_Colors.scss']}
31+
>
2932
Colored snackbars
3033
</Demo>
3134

packages/site/src/site.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@
2727
@use './routes/demo/linear-progress/_Colored.scss' as linear-progress-colored;
2828
@use './routes/demo/menu-surface/_ManualAnchor.scss';
2929
@use './routes/demo/paper/_CustomColor.scss' as paper-custom-color;
30+
@use './routes/demo/snackbar/_Colors.scss';
3031
@use './routes/demo/typography/_Typography.scss';

0 commit comments

Comments
 (0)