Skip to content

Commit 4506344

Browse files
committed
Add demo for new features
1 parent 23ec5a5 commit 4506344

File tree

1 file changed

+59
-8
lines changed

1 file changed

+59
-8
lines changed

docs/App.svelte

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const handleClick = btn => {
1717
selected = btn.name
1818
code = btn.code
1919
btn.run()
20-
gtag('event', 'toast', { event_label: btn.name })
20+
gtag('event', `toast:${camelCase(btn.name)}`)
2121
}
2222
2323
const buttons = [
@@ -85,10 +85,7 @@ toast.pop()
8585
8686
// Or remove a particular one
8787
const id = toast.push('Yo!')
88-
toast.pop(id)
89-
90-
// Or remove all active toasts
91-
toast.pop(0)`,
88+
toast.pop(id)`,
9289
run: () => {
9390
toast.pop()
9491
}
@@ -188,9 +185,47 @@ toast.set(id, { progress: 1 })`,
188185
await tick()
189186
toast.push('All themes reset!')
190187
}
188+
},
189+
{
190+
name: 'CREATE NEW TOAST CONTAINER',
191+
code: `<style>
192+
.wrap {
193+
--toastContainerTop: 0.5rem;
194+
--toastContainerRight: 2rem;
195+
--toastContainerBottom: auto;
196+
--toastContainerLeft: 2rem;
197+
--toastWidth: 100%;
198+
--toastMinHeight: 1.5rem;
199+
--toastBackground: rgba(59,130,246,0.95);
200+
--toastMsgPadding: 0.25rem 0.5rem;
201+
font-size: 0.875rem;
202+
}
203+
</style>
204+
205+
<div class="wrap">
206+
<SvelteToast target="new" options={{ initial: 0, intro: { y: -64 } }} />
207+
</div>
208+
209+
<script>
210+
// Send toast to "new" container
211+
toast.push('NEW: Multiple toast container support', { target: 'new' })
212+
<\/script>`, // eslint-disable-line no-useless-escape
213+
run: () => {
214+
toast.push('NEW: Multiple toast container support', { target: 'new' })
215+
}
216+
},
217+
{
218+
name: 'REMOVE ALL TOASTS FROM CONTAINER',
219+
code: `// Remove all toasts from "new" container
220+
toast.pop(i => i.target !== 'new')
221+
222+
// Or remove ALL active toasts from ALL containers
223+
toast.pop(0)`,
224+
run: () => {
225+
toast.pop(i => i.target !== 'new')
226+
}
191227
}
192228
]
193-
194229
</script>
195230

196231
<style>
@@ -205,6 +240,17 @@ toast.set(id, { progress: 1 })`,
205240
--toastContainerBottom: 8rem;
206241
--toastContainerLeft: calc(50vw - 8rem);
207242
}
243+
.top {
244+
--toastContainerTop: 0.5rem;
245+
--toastContainerRight: 2rem;
246+
--toastContainerBottom: auto;
247+
--toastContainerLeft: 2rem;
248+
--toastWidth: 100%;
249+
--toastMinHeight: 1.5rem;
250+
--toastBackground: rgba(59,130,246,0.95);
251+
--toastMsgPadding: 0.25rem 0.5rem;
252+
font-size: 0.875rem;
253+
}
208254
</style>
209255

210256
<div class="container">
@@ -220,13 +266,18 @@ toast.set(id, { progress: 1 })`,
220266
<button
221267
class:selected={selected === btn.name}
222268
on:click={() => { handleClick(btn) }}
223-
data-btn={camelCase(btn.name)}
224-
>{btn.name}</button>
269+
data-btn={camelCase(btn.name)}>
270+
{btn.name}
271+
</button>
225272
{/each}
226273

227274
</div>
228275
</div>
229276

277+
<div class="top">
278+
<SvelteToast options={{ initial: 0, intro: { y: -64 } }} target="new" />
279+
</div>
280+
230281
<div class:colors class:bottom>
231282
<SvelteToast {options} />
232283
</div>

0 commit comments

Comments
 (0)