|
8 | 8 | let { data } = $props(); |
9 | 9 | </script> |
10 | 10 |
|
11 | | -{#if navigating.to} |
| 11 | +{#snippet loading()} |
12 | 12 | <span class="inline-flex items-center justify-center"> |
13 | 13 | <LoaderCircle class="mr-2 size-4 animate-spin" /> |
14 | 14 | Loading... |
15 | 15 | </span> |
| 16 | +{/snippet} |
| 17 | + |
| 18 | +{#if navigating.to} |
| 19 | + {@render loading()} |
16 | 20 | {:else} |
17 | | - <div class="my-8 *:last:mt-4"> |
18 | | - <h1 class="text-5xl font-semibold text-primary">{data.currentPackage.packageName}</h1> |
19 | | - <h2 class="text-xl text-muted-foreground"> |
20 | | - {data.currentPackage.owner}/{data.currentPackage.repoName} |
21 | | - </h2> |
22 | | - <h3 class="italic">*insert description*</h3> |
23 | | - </div> |
24 | | - <div class="flex gap-8"> |
25 | | - <Accordion.Root |
26 | | - type="multiple" |
27 | | - value={data.releases |
28 | | - // Only expand releases that are less than a week old |
29 | | - .filter(({ created_at }) => { |
30 | | - return new Date(created_at).getTime() > new Date().getTime() - 1000 * 60 * 60 * 24 * 7; |
31 | | - }) |
32 | | - .map(({ id }) => id.toString())} |
33 | | - class="w-full" |
34 | | - > |
35 | | - {#each data.releases as release (release.id)} |
36 | | - <ReleaseCard |
37 | | - packageName={data.currentPackage.packageName} |
38 | | - repo={{ owner: data.currentPackage.owner, name: data.currentPackage.repoName }} |
39 | | - {release} |
40 | | - /> |
41 | | - {/each} |
42 | | - </Accordion.Root> |
43 | | - <SidePanel |
44 | | - packageName={data.currentPackage.packageName} |
45 | | - allPackages={data.displayablePackages} |
46 | | - class="h-fit w-2/5" |
47 | | - /> |
48 | | - </div> |
| 21 | + <!-- Required to avoid a layout shift/hydration mismatch for some reason --> |
| 22 | + {#await Promise.resolve()} |
| 23 | + {@render loading()} |
| 24 | + {:then} |
| 25 | + <div class="my-8"> |
| 26 | + <h1 class="text-5xl font-semibold text-primary">{data.currentPackage.packageName}</h1> |
| 27 | + <h2 class="text-xl text-muted-foreground"> |
| 28 | + {data.currentPackage.owner}/{data.currentPackage.repoName} |
| 29 | + </h2> |
| 30 | + </div> |
| 31 | + <div class="flex gap-8"> |
| 32 | + <Accordion.Root |
| 33 | + type="multiple" |
| 34 | + value={data.releases |
| 35 | + // Only expand releases that are less than a week old |
| 36 | + .filter(({ created_at }) => { |
| 37 | + return new Date(created_at).getTime() > new Date().getTime() - 1000 * 60 * 60 * 24 * 7; |
| 38 | + }) |
| 39 | + .map(({ id }) => id.toString())} |
| 40 | + class="w-full" |
| 41 | + > |
| 42 | + {#each data.releases as release (release.id)} |
| 43 | + <ReleaseCard |
| 44 | + packageName={data.currentPackage.packageName} |
| 45 | + repo={{ owner: data.currentPackage.owner, name: data.currentPackage.repoName }} |
| 46 | + {release} |
| 47 | + /> |
| 48 | + {/each} |
| 49 | + </Accordion.Root> |
| 50 | + <SidePanel |
| 51 | + packageName={data.currentPackage.packageName} |
| 52 | + allPackages={data.displayablePackages} |
| 53 | + class="h-fit w-2/5" |
| 54 | + /> |
| 55 | + </div> |
| 56 | + {/await} |
49 | 57 | {/if} |
0 commit comments