From 0cea58922ddebb2ed1d9eabcb26dc1ffa128c1ae Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Sun, 21 Jul 2024 09:42:48 +0000 Subject: [PATCH] web/changelogs: display skeleton when changelog is loading --- .../changelog/ChangelogEntry.svelte | 17 ++- .../changelog/ChangelogSkeleton.svelte | 128 ++++++++++++++++++ web/src/components/misc/Skeleton.svelte | 64 +++++++++ web/src/lib/types/changelogs.ts | 2 +- web/src/routes/updates/+page.svelte | 32 +++-- 5 files changed, 228 insertions(+), 15 deletions(-) create mode 100644 web/src/components/changelog/ChangelogSkeleton.svelte create mode 100644 web/src/components/misc/Skeleton.svelte diff --git a/web/src/components/changelog/ChangelogEntry.svelte b/web/src/components/changelog/ChangelogEntry.svelte index 01116d46..3026a9d4 100644 --- a/web/src/components/changelog/ChangelogEntry.svelte +++ b/web/src/components/changelog/ChangelogEntry.svelte @@ -1,9 +1,13 @@ + +
+
+
+
{ version }
+
+ +
+
+

+ +

+
+
+ +
+ {#each {length: 3 + Math.random() * 5} as _} +

+ +

+ {/each} +
+
+
+ + diff --git a/web/src/components/misc/Skeleton.svelte b/web/src/components/misc/Skeleton.svelte new file mode 100644 index 00000000..91e39e48 --- /dev/null +++ b/web/src/components/misc/Skeleton.svelte @@ -0,0 +1,64 @@ + + +
+ + \ No newline at end of file diff --git a/web/src/lib/types/changelogs.ts b/web/src/lib/types/changelogs.ts index 3dd41afc..e4d73c5d 100644 --- a/web/src/lib/types/changelogs.ts +++ b/web/src/lib/types/changelogs.ts @@ -16,4 +16,4 @@ export interface MarkdownMetadata { export type ChangelogImport = { default: SvelteComponent, metadata: ChangelogMetadata -} | undefined; +}; \ No newline at end of file diff --git a/web/src/routes/updates/+page.svelte b/web/src/routes/updates/+page.svelte index 11d4d959..0ebce5cd 100644 --- a/web/src/routes/updates/+page.svelte +++ b/web/src/routes/updates/+page.svelte @@ -5,13 +5,15 @@ import { getAllChangelogs } from "$lib/changelogs"; import type { ChangelogImport } from "$lib/types/changelogs"; + import ChangelogSkeleton from "$components/changelog/ChangelogSkeleton.svelte"; + import IconChevronLeft from "@tabler/icons-svelte/IconChevronLeft.svelte"; import IconChevronRight from "@tabler/icons-svelte/IconChevronRight.svelte"; const changelogs = getAllChangelogs(); const versions = Object.keys(changelogs); - let changelog: (ChangelogImport & { version: string }) | undefined; + let changelog: { version: string; page: Promise } | undefined; let currentIndex = 0; { @@ -24,17 +26,13 @@ const loadChangelog = async () => { const version = versions[currentIndex]; - const log = (await changelogs[version]()) as ChangelogImport; - if (!log) { - return; // FIXME: now wot + changelog = { + version, + page: changelogs[version]() as Promise } - changelog = { - ...log, - version, - }; - window.location.hash = version; + await changelog.page; }; const loadNext = () => { @@ -77,10 +75,17 @@
- + {#await changelog.page} + {#key changelog.version} + + {/key} + {:then page} + + {/await}