Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/lib/Notifications.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ul class="toasts">
<ul class="toasts" bind:this={toastsElement}>
{#each toasts as toast (toast.id)}
<li class="toast" style="background: {toast.background};" out:animateOut>
{#if toast.persist}
Expand Down Expand Up @@ -166,7 +166,7 @@

@keyframes shrink {
0% {
width: 40vw;
width: var(--width);
}
100% {
width: 0;
Expand All @@ -176,7 +176,7 @@

@media screen and (min-width: 600px) {
.toasts > .toast {
min-width: 40vw;
min-width: var(--width);
min-height: auto;
}

Expand All @@ -188,7 +188,7 @@

<script>
import { notification } from './store.js'
import { onDestroy } from 'svelte'
import { onMount, onDestroy } from 'svelte'

export let themes = {
danger: '#bb2124',
Expand All @@ -199,11 +199,17 @@
}

export let timeout = 3000
export let width = '40vw'

let count = 0
let toasts = [ ]
let toastsElement;
let unsubscribe

onMount(() => {
toastsElement.style.setProperty('--width', width);
});

function animateOut (node, { delay = 0, duration = 1000 }) {
return {
delay,
Expand Down