From cb40705270742c995092140e8e0a8c7f9173ccc6 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Fri, 15 Dec 2023 13:42:29 -0800 Subject: [PATCH] Tweak router and modals --- src/app/Routes.svelte | 2 +- src/partials/Modal.svelte | 70 +++++++++++++++++++-------------------- src/util/router.ts | 7 ++-- 3 files changed, 38 insertions(+), 41 deletions(-) diff --git a/src/app/Routes.svelte b/src/app/Routes.svelte index befdedf4..e5f4ad15 100644 --- a/src/app/Routes.svelte +++ b/src/app/Routes.svelte @@ -38,7 +38,7 @@ {/key} {#each reverse($modals).filter(m => !m.config.virtual) as m, i (getKey(m) + i)} - + {#key $stateKey} {/key} diff --git a/src/partials/Modal.svelte b/src/partials/Modal.svelte index bb59aef3..866a9f11 100644 --- a/src/partials/Modal.svelte +++ b/src/partials/Modal.svelte @@ -1,22 +1,17 @@ @@ -97,19 +97,17 @@ on:click={tryClose}> - {#if isNested} -
router.clearModals()} - class="pointer-events-auto flex h-10 w-10 cursor-pointer items-center justify-center rounded-full - border border-solid border-cocoa bg-mid text-lightest transition-colors hover:bg-mid"> - -
- {/if} +
router.clearModals()} + class="clear-modals pointer-events-auto flex hidden h-10 w-10 cursor-pointer items-center justify-center + rounded-full border border-solid border-cocoa bg-mid text-lightest transition-colors hover:bg-mid"> + +
{/if} -
+
diff --git a/src/util/router.ts b/src/util/router.ts index 7c7d3a28..a02f8a06 100644 --- a/src/util/router.ts +++ b/src/util/router.ts @@ -136,14 +136,13 @@ export type Route = RegisterOpts & { } export type RouteConfig = { - id?: string + key?: string mini?: boolean modal?: boolean virtual?: boolean noEscape?: boolean replace?: boolean context?: Record - key?: string } export type HistoryItem = { @@ -360,8 +359,8 @@ export class Router { window.history.back() } - remove(id) { - this.history.update(reject(($item: HistoryItem) => $item.config.id === id)) + remove(key) { + this.history.update(reject(($item: HistoryItem) => $item.config.key === key)) } clearModals() {