Skip to content

Commit 5aa07bd

Browse files
committed
Update demo
1 parent 172c1f7 commit 5aa07bd

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

docs/App.svelte

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ toast.pop(0)`,
231231
name: 'SEND COMPONENT AS A MESSAGE',
232232
code: `toast.push({
233233
component: {
234-
src: DummyComponent,
234+
src: DummyComponent, // where \`src\` is a Svelte component
235235
props: {
236236
title: 'A Dummy Cookie Component'
237237
},
238-
sendIdTo: 'toastId'
238+
sendIdTo: 'toastId' // send toast id to \`toastId\` prop
239239
},
240240
dismissable: false,
241241
initial: 0,
@@ -251,6 +251,13 @@ toast.pop(0)`,
251251
theme: { '--toastMsgPadding': '0' }
252252
})
253253
}
254+
},
255+
{
256+
name: 'PAUSE ON MOUSE HOVER',
257+
code: `toast.push('Hover me!', { pausable: true })`, // eslint-disable-line
258+
run: () => {
259+
toast.push('Hover me!', { pausable: true })
260+
}
254261
}
255262
]
256263
</script>

docs/Dummy.svelte

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@ import { toast } from '../src'
44
export let toastId
55
export let title
66
7-
const clicked = () => toast.pop(toastId)
7+
const clicked = ok => {
8+
toast.pop(toastId)
9+
toast.push({
10+
msg: ok ? 'Accepted!' : 'Declined!',
11+
target: 'new',
12+
theme: {
13+
'--toastBackground': ok ? '#48BB78' : '#F56565'
14+
}
15+
})
16+
}
17+
const accepted = () => clicked(true)
18+
const declined = () => clicked(false)
819
</script>
920

1021
<div class="w-full h-48 bg-yellow-500 rounded-sm flex flex-col">
1122
<h1 class="font-bold m-2">{title}</h1>
12-
<p class="text-sm mx-2 mb-1">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
23+
<p class="text-sm mx-2 mb-1"><span class="font-mono font-bold">toastId={toastId}</span>. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
1324
<div class="flex-1 flex flex-row justify-between">
14-
<button class="w-28" on:click={clicked}>DECLINE</button>
15-
<button class="w-28" on:click={clicked} data-btn="dummyAccept">ACCEPT</button>
25+
<button class="w-28" on:click={declined}>DECLINE</button>
26+
<button class="w-28" on:click={accepted} data-btn="dummyAccept">ACCEPT</button>
1627
</div>
1728
</div>

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ <h1 class="text-4xl text-center">svelte-toast</h1>
3838
<p class="container px-2 mb-4">
3939
Simple, elegant, generic, flexible and performant toast notifications.
4040
Because a demo helps better than a thousand API docs, so here it is.
41-
Use in Vanilla JS (6kb gzipped) or as a Svelte component.
41+
Use in Vanilla JS (7kb gzipped) or as a Svelte component.
4242
</p>
4343
</body>
4444
</html>

0 commit comments

Comments
 (0)