From 1b71b6a1197967271528fd0d5b9ff5fc9a1f3c26 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 11 Jan 2024 18:45:31 -0800 Subject: feat: notifications --- src/lib/Notification/Notification.svelte | 112 +++++++++++++++++++++++++++++++ src/lib/Notification/options.ts | 19 ++++++ src/lib/Settings/Categories/Debug.svelte | 26 ++++++- 3 files changed, 155 insertions(+), 2 deletions(-) create mode 100644 src/lib/Notification/Notification.svelte create mode 100644 src/lib/Notification/options.ts (limited to 'src/lib') diff --git a/src/lib/Notification/Notification.svelte b/src/lib/Notification/Notification.svelte new file mode 100644 index 00000000..9612d526 --- /dev/null +++ b/src/lib/Notification/Notification.svelte @@ -0,0 +1,112 @@ + + +
+ {#if notification.description} +
+ {@html notification.heading} + + {@html notification.description} + +
+ +
+ +
+
+ {:else} +
+ {@html notification.heading} + +     + +
+ +
+
+ {/if} +
+ + diff --git a/src/lib/Notification/options.ts b/src/lib/Notification/options.ts new file mode 100644 index 00000000..f14e0d25 --- /dev/null +++ b/src/lib/Notification/options.ts @@ -0,0 +1,19 @@ +type Position = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'; + +interface Options { + heading: string | number; + description: string | number | undefined; + position: Position; + duration: number; + id: string; +} + +export const options = (preferences: { [key: string]: number | string }): Options => { + return { + position: (preferences.position || 'top-right') as Position, + duration: Number(preferences.duration || 3000), + heading: preferences.heading || 'Notification', + description: preferences.description || undefined, + id: Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15) + }; +}; diff --git a/src/lib/Settings/Categories/Debug.svelte b/src/lib/Settings/Categories/Debug.svelte index 5f6be96b..c21b6dd7 100644 --- a/src/lib/Settings/Categories/Debug.svelte +++ b/src/lib/Settings/Categories/Debug.svelte @@ -1,16 +1,38 @@ - + Resets all settings present on this page to their default values

- + Resets all of your settings to their default values and clears both AniList media list and manga data caches -- cgit v1.2.3