From 2c764a787c83d1176f5aa6bfbe5f9403da437886 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 24 Jun 2020 16:10:54 +0100 Subject: [PATCH] custom notifications solution --- packages/builder/src/App.svelte | 2 +- .../src/builderStore/store/notifications.js | 12 +- .../src/components/common/Notification.svelte | 119 ------------------ .../Notification/NotificationDisplay.svelte | 61 +++++++++ 4 files changed, 71 insertions(+), 123 deletions(-) delete mode 100644 packages/builder/src/components/common/Notification.svelte create mode 100644 packages/builder/src/components/common/Notification/NotificationDisplay.svelte diff --git a/packages/builder/src/App.svelte b/packages/builder/src/App.svelte index 7cf7fb864b..76ef32a669 100644 --- a/packages/builder/src/App.svelte +++ b/packages/builder/src/App.svelte @@ -4,7 +4,7 @@ import { Router, basepath } from "@sveltech/routify" import { routes } from "../routify/routes" import { store, initialise } from "builderStore" - import NotificationDisplay from "components/common/Notification.svelte"; + import NotificationDisplay from "components/common/Notification/NotificationDisplay.svelte"; $basepath = "/_builder" diff --git a/packages/builder/src/builderStore/store/notifications.js b/packages/builder/src/builderStore/store/notifications.js index cb789b2aef..201e13e4b9 100644 --- a/packages/builder/src/builderStore/store/notifications.js +++ b/packages/builder/src/builderStore/store/notifications.js @@ -1,9 +1,15 @@ import { writable } from 'svelte/store' +import { generate } from "shortid" -export const notificationStore = writable() +export const notificationStore = writable({ + notifications: [] +}) -export function send(message, type = 'default', timeout) { - notificationStore.set({ type, message, timeout }) +export function send(message, type = 'default') { + notificationStore.update(state => { + state.notifications = [...state.notifications, { id: generate(), type, message }] + return state + }) } export const notifier = { diff --git a/packages/builder/src/components/common/Notification.svelte b/packages/builder/src/components/common/Notification.svelte deleted file mode 100644 index 2503db0b8f..0000000000 --- a/packages/builder/src/components/common/Notification.svelte +++ /dev/null @@ -1,119 +0,0 @@ - - - - - diff --git a/packages/builder/src/components/common/Notification/NotificationDisplay.svelte b/packages/builder/src/components/common/Notification/NotificationDisplay.svelte new file mode 100644 index 0000000000..cfd39ad068 --- /dev/null +++ b/packages/builder/src/components/common/Notification/NotificationDisplay.svelte @@ -0,0 +1,61 @@ + + + + +