|
@@ -0,0 +1,97 @@
|
|
|
|
|
+<script>
|
|
|
|
|
+ import { fly } from "svelte/transition";
|
|
|
|
|
+ import { toastStore, dismiss } from "$lib/toast.svelte.js";
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<div class="toaster">
|
|
|
|
|
+ {#each toastStore.items as t (t.id)}
|
|
|
|
|
+ <div class="toast {t.type}" transition:fly={{ x: 60, duration: 250, opacity: 0 }}>
|
|
|
|
|
+ <span class="icon">
|
|
|
|
|
+ {#if t.type === "success"}
|
|
|
|
|
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
|
|
|
+ <polyline points="20 6 9 17 4 12"/>
|
|
|
|
|
+ </svg>
|
|
|
|
|
+ {:else}
|
|
|
|
|
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
|
|
|
+ <line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
|
|
|
|
|
+ </svg>
|
|
|
|
|
+ {/if}
|
|
|
|
|
+ </span>
|
|
|
|
|
+ <span class="message">{t.message}</span>
|
|
|
|
|
+ <button class="close" onclick={() => dismiss(t.id)} aria-label="Dismiss">
|
|
|
|
|
+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
|
|
|
+ <line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
|
|
|
|
|
+ </svg>
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ {/each}
|
|
|
|
|
+</div>
|
|
|
|
|
+
|
|
|
|
|
+<style>
|
|
|
|
|
+ .toaster {
|
|
|
|
|
+ position: fixed;
|
|
|
|
|
+ top: 1.5rem;
|
|
|
|
|
+ right: 1.5rem;
|
|
|
|
|
+ z-index: 9999;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ flex-direction: column;
|
|
|
|
|
+ gap: 0.625rem;
|
|
|
|
|
+ pointer-events: none;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .toast {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ gap: 0.625rem;
|
|
|
|
|
+ padding: 0.75rem 1rem;
|
|
|
|
|
+ border-radius: 10px;
|
|
|
|
|
+ font-size: 0.9rem;
|
|
|
|
|
+ font-weight: 500;
|
|
|
|
|
+ min-width: 260px;
|
|
|
|
|
+ max-width: 380px;
|
|
|
|
|
+ pointer-events: all;
|
|
|
|
|
+ border: 1px solid transparent;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .toast.success {
|
|
|
|
|
+ background: #0f2a1a;
|
|
|
|
|
+ border-color: #1a5c30;
|
|
|
|
|
+ color: #4ade80;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .toast.error {
|
|
|
|
|
+ background: #2a0f0f;
|
|
|
|
|
+ border-color: #5c1a1a;
|
|
|
|
|
+ color: #f87171;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .icon {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ flex-shrink: 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .message {
|
|
|
|
|
+ flex: 1;
|
|
|
|
|
+ color: #e8e8f0;
|
|
|
|
|
+ line-height: 1.4;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .close {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ justify-content: center;
|
|
|
|
|
+ background: none;
|
|
|
|
|
+ border: none;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ color: #666;
|
|
|
|
|
+ padding: 2px;
|
|
|
|
|
+ flex-shrink: 0;
|
|
|
|
|
+ border-radius: 4px;
|
|
|
|
|
+ transition: color 0.15s;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .close:hover {
|
|
|
|
|
+ color: #aaa;
|
|
|
|
|
+ }
|
|
|
|
|
+</style>
|