feat: notification transitions

This commit is contained in:
tglide committed 2022-12-05 16:31:43 +00:00
1 parent f29d619506
commit 67f5225e18
2 files changed
+14 -8

No files matched your search

+4 -1
View File
@@ -1,5 +1,7 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte';
import { fly } from 'svelte/transition';
import { flip } from 'svelte/animate';
import type { Notification } from '../stores/notifications';
export let type: Notification['type'] = 'info';
@@ -14,7 +16,8 @@
class:is-success={type === 'success'}
class:is-warning={type === 'warning'}
class:is-danger={type === 'error'}
class:is-info={type === 'info'}>
class:is-info={type === 'info'}
transition:fly={{ x: 50 }}>
<button class="x-button" aria-label="close alert" on:click={() => dispatch('dismiss')}>
<span class="icon-x" aria-hidden="true" />
</button>
+10 -7
View File
@@ -1,19 +1,22 @@
<script lang="ts">
import Notification from './notification.svelte';
import { dismissNotification, notifications } from '../stores/notifications';
import { flip } from 'svelte/animate';
</script>
{#if $notifications}
<section>
<ul class="u-flex u-flex-vertical u-gap-16">
{#each $notifications as notification (notification.id)}
<Notification
type={notification.type}
title={notification.title}
on:dismiss={() => dismissNotification(notification.id)}
buttons={notification?.buttons}>
{notification.message}
</Notification>
<div animate:flip={{ duration: 500 }}>
<Notification
type={notification.type}
title={notification.title}
on:dismiss={() => dismissNotification(notification.id)}
buttons={notification?.buttons}>
{notification.message}
</Notification>
</div>
{/each}
</ul>
</section>