From ca3b07b7448bd1959402de8bd7745e07c3676c7b Mon Sep 17 00:00:00 2001 From: Allan Lasser Date: Wed, 27 Nov 2024 13:30:04 -0500 Subject: [PATCH 1/3] Add support for updating toasts --- src/lib/components/layouts/Toaster.svelte | 24 ++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/lib/components/layouts/Toaster.svelte b/src/lib/components/layouts/Toaster.svelte index 0bd2a88f2..bfdc936af 100644 --- a/src/lib/components/layouts/Toaster.svelte +++ b/src/lib/components/layouts/Toaster.svelte @@ -15,18 +15,28 @@ contents: ToastContents; } - function addToast(newToast: ToastItem, prev: ToastItem[]) { - const id = Date.now(); - return [...prev, { ...newToast, id }]; - } - export const toasts = writable([]); export function toast

( contents: ToastContents, options: ToastOptions

= {}, - ) { - toasts.update((prev) => addToast({ contents, ...options }, prev)); + ): number { + const newToast = { id: Date.now(), contents, ...options }; + toasts.update((prev) => [...prev, newToast]); + // Return the ID so we can update the toast later + return newToast.id; + } + + export function updateToast

( + id: number, + contents: ToastContents, + options: ToastOptions

= {}, + ): void { + toasts.update((prev) => + prev.map((toast) => + toast.id === id ? { ...toast, contents, ...options } : toast, + ), + ); } From 484233147ae95a6b85b3b2d4b4268d3c1dc59135 Mon Sep 17 00:00:00 2001 From: Allan Lasser Date: Wed, 27 Nov 2024 13:30:12 -0500 Subject: [PATCH 2/3] Update toast timeout to 3s --- src/config/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/config.js b/src/config/config.js index 0943e8ff2..1917e7504 100644 --- a/src/config/config.js +++ b/src/config/config.js @@ -90,7 +90,7 @@ export const PDF_SIZE_LIMIT_READABLE = "500 MB"; export const DOCUMENT_SIZE_LIMIT = 27262976; export const DOCUMENT_SIZE_LIMIT_READABLE = "25 MB"; -export const TOAST_LENGTH = 2500; +export const TOAST_LENGTH = 3000; export const TOAST_FADE = 800; export const LEGACY_CUT_OFF = 20000000; From 839acfb0bb8a74ac3b2ae27a92e272332da379fb Mon Sep 17 00:00:00 2001 From: Allan Lasser Date: Wed, 27 Nov 2024 13:30:21 -0500 Subject: [PATCH 3/3] More pronounced toast shadow --- src/lib/components/common/Toast.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/components/common/Toast.svelte b/src/lib/components/common/Toast.svelte index 9b5d8e711..cab532adb 100644 --- a/src/lib/components/common/Toast.svelte +++ b/src/lib/components/common/Toast.svelte @@ -81,7 +81,7 @@ .toast { padding: 0.5rem 0.5rem; border-radius: 0.5rem; - box-shadow: var(--shadow-3); + box-shadow: var(--shadow-2); display: inline-flex; align-items: flex-start; width: 100%;