Skip to content

Commit 4e62776

Browse files
committed
Merge branch 'JWorthington97-demo-add-colour-snackbars'
2 parents 99a066b + 142ef63 commit 4e62776

File tree

4 files changed

+85
-0
lines changed

4 files changed

+85
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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';
6+
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+
);
12+
}
13+
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+
);
19+
}
20+
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+
);
26+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
>
5+
<Actions>
6+
<IconButton class="material-icons" title="Dismiss">close</IconButton>
7+
</Actions>
8+
</Snackbar>
9+
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+
>
14+
<Actions>
15+
<IconButton class="material-icons" title="Dismiss">close</IconButton>
16+
</Actions>
17+
</Snackbar>
18+
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+
>
24+
<Actions>
25+
<IconButton class="material-icons" title="Dismiss">close</IconButton>
26+
</Actions>
27+
</Snackbar>
28+
29+
<Button on:click={() => snackbarSuccess && snackbarSuccess.open()}>
30+
<Label>Open Success Snackbar</Label>
31+
</Button>
32+
33+
<Button on:click={() => snackbarWarning && snackbarWarning.open()}>
34+
<Label>Open Warning Snackbar</Label>
35+
</Button>
36+
37+
<Button on:click={() => snackbarError && snackbarError.open()}>
38+
<Label>Open Error Snackbar</Label>
39+
</Button>
40+
41+
<script lang="ts">
42+
import type { SnackbarComponentDev } from '@smui/snackbar';
43+
import Snackbar, { Label, Actions } from '@smui/snackbar';
44+
import IconButton from '@smui/icon-button';
45+
import Button from '@smui/button';
46+
47+
let snackbarSuccess: SnackbarComponentDev;
48+
let snackbarWarning: SnackbarComponentDev;
49+
let snackbarError: SnackbarComponentDev;
50+
</script>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525
Using dynamic text
2626
</Demo>
2727

28+
<Demo
29+
component={Colors}
30+
files={['snackbar/_Colors.svelte', 'snackbar/_Colors.scss']}
31+
>
32+
Colored snackbars
33+
</Demo>
34+
2835
<Demo component={Kitchen} file="snackbar/_Kitchen.svelte">
2936
The "Kitchen" Snackbar generator
3037
</Demo>
@@ -37,5 +44,6 @@
3744
import LeadingWithAction from './_LeadingWithAction.svelte';
3845
import StackedWithAction from './_StackedWithAction.svelte';
3946
import DynamicText from './_DynamicText.svelte';
47+
import Colors from './_Colors.svelte';
4048
import Kitchen from './_Kitchen.svelte';
4149
</script>

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)