From 811d23fc05f69c72b6d9cac0ccfeb30a36d09352 Mon Sep 17 00:00:00 2001 From: Kohei Yoshino Date: Sun, 22 Dec 2024 15:18:50 -0500 Subject: [PATCH] Migrate to Runes, part 3 --- .../components/contents/contents-page.svelte | 4 +- .../contents/details/backup-feedback.svelte | 30 ++-- .../details/content-details-overlay.svelte | 120 +++++++------- .../details/editor/copy-menu-items.svelte | 41 ++--- .../details/editor/entry-editor.svelte | 14 +- .../details/editor/field-editor.svelte | 151 ++++++++++-------- .../details/editor/translate-button.svelte | 40 ++--- .../editor/translator-api-key-dialog.svelte | 9 +- .../contents/details/pane-body.svelte | 49 +++--- .../contents/details/pane-header.svelte | 72 +++++---- .../details/preview/entry-preview.svelte | 14 +- .../details/preview/field-preview.svelte | 69 ++++---- .../contents/details/toolbar.svelte | 76 +++++---- .../contents/list/entry-list-item.svelte | 23 +-- .../contents/list/entry-list.svelte | 6 +- .../components/contents/list/file-list.svelte | 2 + .../contents/list/primary-sidebar.svelte | 4 +- .../contents/list/primary-toolbar.svelte | 8 +- .../contents/list/secondary-sidebar.svelte | 7 +- .../contents/list/secondary-toolbar.svelte | 9 +- .../shared/delete-entries-dialog.svelte | 35 ++-- .../shared/entry-parse-errors-toast.svelte | 2 +- 22 files changed, 430 insertions(+), 355 deletions(-) diff --git a/src/lib/components/contents/contents-page.svelte b/src/lib/components/contents/contents-page.svelte index 47b08f3b..bebe1e0a 100644 --- a/src/lib/components/contents/contents-page.svelte +++ b/src/lib/components/contents/contents-page.svelte @@ -23,6 +23,8 @@ const routeRegex = /^\/collections\/(?<_collectionName>[^/]+)(?:\/(?new|entries))?(?:\/(?.+?))?$/; + const MainContent = $derived($selectedCollection?.files ? FileList : EntryList); + /** * Navigate to the content list or content details page given the URL hash. * @todo Show Not Found page. @@ -165,7 +167,7 @@ {/snippet} {#snippet mainContent()} - + {/snippet} {#snippet secondarySidebar()} diff --git a/src/lib/components/contents/details/backup-feedback.svelte b/src/lib/components/contents/details/backup-feedback.svelte index 96af0d55..2366be7d 100644 --- a/src/lib/components/contents/details/backup-feedback.svelte +++ b/src/lib/components/contents/details/backup-feedback.svelte @@ -4,26 +4,28 @@ import { backupToastState, restoreDialogState } from '$lib/services/contents/draft/backup'; import { showContentOverlay } from '$lib/services/contents/draft/editor'; - $: now = new Date(); - $: ({ resolve, timestamp } = $restoreDialogState); - $: sameYear = now.getUTCFullYear() === timestamp?.getUTCFullYear(); - $: sameMonth = sameYear && now.getUTCMonth() === timestamp?.getUTCMonth(); - $: sameDay = sameMonth && now.getUTCDate() === timestamp?.getUTCDate(); - $: datetime = timestamp?.toLocaleString($appLocale ?? undefined, { - year: sameYear ? undefined : 'numeric', - month: sameDay ? undefined : 'short', - day: sameDay ? undefined : 'numeric', - hour: 'numeric', - minute: 'numeric', - }); + const now = $derived(new Date()); + const { resolve, timestamp } = $derived($restoreDialogState); + const sameYear = $derived(now.getUTCFullYear() === timestamp?.getUTCFullYear()); + const sameMonth = $derived(sameYear && now.getUTCMonth() === timestamp?.getUTCMonth()); + const sameDay = $derived(sameMonth && now.getUTCDate() === timestamp?.getUTCDate()); + const datetime = $derived( + timestamp?.toLocaleString($appLocale ?? undefined, { + year: sameYear ? undefined : 'numeric', + month: sameDay ? undefined : 'short', + day: sameDay ? undefined : 'numeric', + hour: 'numeric', + minute: 'numeric', + }), + ); - $: { + $effect(() => { if (!$showContentOverlay && $restoreDialogState.show) { // Close the dialog when the Content Editor is closed $restoreDialogState.show = false; resolve?.(); } - } + });