feat(ui): animate toasts
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { fly, slide } from 'svelte/transition';
|
||||||
import { toasts } from './toast.svelte';
|
import { toasts } from './toast.svelte';
|
||||||
|
|
||||||
const typeClasses: Record<string, string> = {
|
const typeClasses: Record<string, string> = {
|
||||||
@@ -9,28 +10,22 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="fixed bottom-4 right-4 flex flex-col gap-2 z-[9999] pointer-events-none"
|
class="fixed bottom-4 right-4 flex flex-col items-end gap-2 z-9999 pointer-events-none"
|
||||||
role="status"
|
role="status"
|
||||||
aria-live="polite"
|
aria-live="polite"
|
||||||
aria-atomic="false"
|
aria-atomic="false"
|
||||||
>
|
>
|
||||||
{#each toasts.value as item (item.id)}
|
{#each toasts.value as item (item.id)}
|
||||||
<div
|
<div
|
||||||
|
in:slide={{ duration: 250 }}
|
||||||
|
out:fly={{ x: 100, duration: 250 }}
|
||||||
class="
|
class="
|
||||||
bg-layer-2 text-text border border-outline rounded
|
bg-layer-2 text-text border border-outline rounded
|
||||||
px-3.5 py-2 text-sm min-w-[180px] max-w-xs
|
px-3.5 py-2 text-sm min-w-45 max-w-xs w-fit
|
||||||
border-l-3 {typeClasses[item.type] ?? 'border-l-outline'}
|
border-l-3 {typeClasses[item.type] ?? 'border-l-outline'}
|
||||||
animate-[slide-in_0.18s_ease]
|
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
{item.message}
|
{item.message}
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
|
||||||
@keyframes slide-in {
|
|
||||||
from { opacity: 0; transform: translateX(12px); }
|
|
||||||
to { opacity: 1; transform: translateX(0); }
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user