flotilla/src/app/components/Toast.svelte

26 lines
792 B
Svelte
Raw Normal View History

2024-08-08 23:32:46 +00:00
<script lang="ts">
import {fly} from "@lib/transition"
2024-11-18 23:58:40 +00:00
import Icon from "@lib/components/Icon.svelte"
import Button from "@lib/components/Button.svelte"
import {toast, popToast} from "@app/toast"
2024-08-08 23:32:46 +00:00
</script>
{#if $toast}
2024-08-23 20:33:36 +00:00
{@const theme = $toast.theme || "info"}
<div transition:fly class="toast z-toast">
{#key $toast.id}
2024-08-16 17:50:38 +00:00
<div
role="alert"
2024-11-27 00:39:49 +00:00
class="alert flex justify-center whitespace-normal text-left"
2024-10-15 18:48:11 +00:00
class:bg-base-100={theme === "info"}
class:text-base-content={theme === "info"}
2024-08-23 20:33:36 +00:00
class:alert-error={theme === "error"}>
2024-08-08 23:32:46 +00:00
{$toast.message}
<Button class="flex items-center opacity-75" onclick={() => popToast($toast.id)}>
2024-11-18 23:58:40 +00:00
<Icon icon="close-circle" />
</Button>
2024-08-08 23:32:46 +00:00
</div>
{/key}
</div>
2024-08-08 23:32:46 +00:00
{/if}