From a2427251f4f411c7a264c5effce81ae2dbd67aa8 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 15 Jun 2022 17:44:16 +0200 Subject: [PATCH] feat: notifications can have buttons --- src/lib/layout/notification.svelte | 20 ++++++++++---------- src/lib/layout/notifications.svelte | 3 ++- src/lib/stores/notifications.ts | 6 ++++++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/lib/layout/notification.svelte b/src/lib/layout/notification.svelte index 01ee630e9..ca5b33c4b 100644 --- a/src/lib/layout/notification.svelte +++ b/src/lib/layout/notification.svelte @@ -4,6 +4,7 @@ export let type: Notification['type'] = 'info'; export let title: Notification['title']; + export let func: Notification['func']; let icon: string; switch (type) { @@ -43,14 +44,13 @@ {/if}

- + {#if func} +
+ {#each func as f} + + {/each} +
+ {/if} diff --git a/src/lib/layout/notifications.svelte b/src/lib/layout/notifications.svelte index 547ae8def..dde7dcdda 100644 --- a/src/lib/layout/notifications.svelte +++ b/src/lib/layout/notifications.svelte @@ -10,7 +10,8 @@ dismissNotification(notification.id)}> + on:dismiss={() => dismissNotification(notification.id)} + func={notification?.func}> {notification.message} {/each} diff --git a/src/lib/stores/notifications.ts b/src/lib/stores/notifications.ts index 5a9fffe9d..ce67f7899 100644 --- a/src/lib/stores/notifications.ts +++ b/src/lib/stores/notifications.ts @@ -7,6 +7,12 @@ export type Notification = { timeout?: number; message: string; title?: string; + func?: Func[]; +}; + +export type Func = { + method: () => void; //TODO Check if promise is needed rather tha () => void + name: string; }; let counter = 0;