From 4068bb7a33dd0f8ebe8b6a05ffccc5f5cfec2bc9 Mon Sep 17 00:00:00 2001 From: kandrusyak Date: Sun, 27 Nov 2022 18:25:23 +0300 Subject: [PATCH] add notifications --- .../Notifications/NotificationItem.vue | 86 +++++++++++++++++++ .../Notifications/TheNotificationProvider.vue | 59 +++++++++++++ .../Notifications/notificationContext.js | 16 ++++ src/pages/settings/TheSettings.vue | 17 +++- 4 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 src/components/Notifications/NotificationItem.vue create mode 100644 src/components/Notifications/TheNotificationProvider.vue create mode 100644 src/components/Notifications/notificationContext.js diff --git a/src/components/Notifications/NotificationItem.vue b/src/components/Notifications/NotificationItem.vue new file mode 100644 index 0000000..ca2f851 --- /dev/null +++ b/src/components/Notifications/NotificationItem.vue @@ -0,0 +1,86 @@ + + + + + diff --git a/src/components/Notifications/TheNotificationProvider.vue b/src/components/Notifications/TheNotificationProvider.vue new file mode 100644 index 0000000..c887e28 --- /dev/null +++ b/src/components/Notifications/TheNotificationProvider.vue @@ -0,0 +1,59 @@ + + + + + diff --git a/src/components/Notifications/notificationContext.js b/src/components/Notifications/notificationContext.js new file mode 100644 index 0000000..2615aca --- /dev/null +++ b/src/components/Notifications/notificationContext.js @@ -0,0 +1,16 @@ +import { reactive } from "vue"; + +export const notifications = reactive({}); + +export const addNotification = (id, title, message, type, lifeTime = 0) => { + notifications[id] = { + title, + message, + type, + lifeTime, + }; +}; + +export const deleteNotification = (id) => { + delete notifications[id]; +}; diff --git a/src/pages/settings/TheSettings.vue b/src/pages/settings/TheSettings.vue index 11458da..d4bdb59 100644 --- a/src/pages/settings/TheSettings.vue +++ b/src/pages/settings/TheSettings.vue @@ -3,15 +3,19 @@ v-select(:items="items", placeholder="Выберите значение", v-model="value" ) BaseButton(@click="showModal = true") Открыть модалку base-modal(v-model="showModal", title="Тестовый заголовок окна" ) + base-button(@click="addNotification") Добавить уведомление + the-notification-provider