school-timetracker/frontend/src/components/ToastNotification.svelte
Patryk Hegenberg e719f4565f feat: add completed Web-Frontend in Svelte with some new Features
- Added import of Schedules
- Added export for schedule table
- Added import of logo
- Added password change to users
- improved ui/ux
2026-01-15 15:19:53 +01:00

34 lines
1.6 KiB
Svelte

<script>
import { toasts, removeToast } from '../lib/stores';
import { fly } from 'svelte/transition';
function getAlertClass(type) {
switch(type) {
case 'error': return 'alert-error';
case 'warning': return 'alert-warning';
case 'success': return 'alert-success';
default: return 'alert-info';
}
}
</script>
<div class="toast toast-top toast-end z-50">
{#each $toasts as toast (toast.id)}
<div
class="alert {getAlertClass(toast.type)} shadow-lg min-w-[300px]"
transition:fly={{ y: -20, duration: 300 }}
>
{#if toast.type === 'error'}
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
{:else if toast.type === 'success'}
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
{:else}
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-current shrink-0 w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
{/if}
<span>{toast.message}</span>
<button class="btn btn-sm btn-ghost" on:click={() => removeToast(toast.id)}>✕</button>
</div>
{/each}
</div>