-
-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathSvelteToast.svelte
More file actions
54 lines (47 loc) · 1.27 KB
/
Copy pathSvelteToast.svelte
File metadata and controls
54 lines (47 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<script>
import { fade, fly } from 'svelte/transition'
import { flip } from 'svelte/animate'
import { toast } from './stores'
import ToastItem from './ToastItem.svelte'
/** @type {import('./stores').SvelteToastOptions} */
export let options = {}
/** @type {(string|'default')} */
export let target = 'default'
let items = []
function getCss(theme) {
let ret = Object.keys(theme).reduce((a, c) => `${a}${c}:${theme[c]};`, '')
console.log('====================================');
console.log(ret);
console.log('====================================');
return ret;
}
$: toast._init(target, options)
$: items = $toast.filter((i) => i.target === target)
</script>
<ul class="_toastContainer">
{#each items as item (item.id)}
<li
class={item.classes.join(' ')}
in:fly={item.intro}
out:fade
animate:flip={{ duration: 200 }}
style={getCss(item.theme)}
>
<ToastItem {item} />
</li>
{/each}
</ul>
<style>
._toastContainer {
top: var(--toastContainerTop, 1.5rem);
right: var(--toastContainerRight, 2rem);
bottom: var(--toastContainerBottom, auto);
left: var(--toastContainerLeft, auto);
position: fixed;
margin: 0;
padding: 0;
list-style-type: none;
pointer-events: none;
z-index: var(--toastContainerZIndex, 9999);
}
</style>