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: 14 additions & 0 deletions src/lib/holocene/toast.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { createEventDispatcher } from 'svelte';
import { twMerge as merge } from 'tailwind-merge';

import type { IconName } from '$lib/holocene/icon';
import Icon from '$lib/holocene/icon/icon.svelte';
import type { ToastVariant } from '$lib/types/holocene';

Expand All @@ -17,10 +18,20 @@
warning: 'bg-warning',
};

const variantIcon: Readonly<Record<ToastVariant, IconName | null>> = {
primary: null,
success: 'success',
error: 'error',
info: 'info',
warning: 'warning',
};

export let id: string;
export let variant: keyof typeof variants;
export let closeButtonLabel: string;

$: icon = variantIcon[variant];

const handleDismiss = () => {
dispatch('dismiss', { id });
};
Expand All @@ -34,6 +45,9 @@
)}
transition:fly={{ x: 250 }}
>
{#if icon}
<Icon name={icon} class="shrink-0" />
{/if}
<p class="text-sm">
<slot />
</p>
Expand Down
Loading