feat: notifications can have buttons

This commit is contained in:
Arman committed 2022-06-15 17:44:16 +02:00
1 parent de526fa5e7
commit a2427251f4
3 files changed
+18 -11

No files matched your search

+10 -10
View File
@@ -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}
<p><slot /></p>
</div>
<!--
<div class="buttons u-flex">
<button class="button is-text is-small">
<span class="text">Action 1</span>
</button>
<button class="button is-text is-small">
<span class="text">Action 2</span>
</button>
</div>
-->
{#if func}
<div class="buttons u-flex">
{#each func as f}
<button class="button is-text is-small" on:click={f.method}>
<span class="text">{f.name}</span>
</button>
{/each}
</div>
{/if}
</li>
+2 -1
View File
@@ -10,7 +10,8 @@
<Notification
type={notification.type}
title={notification.title}
on:dismiss={() => dismissNotification(notification.id)}>
on:dismiss={() => dismissNotification(notification.id)}
func={notification?.func}>
{notification.message}
</Notification>
{/each}
+6
View File
@@ -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;