Skip to content

Commit 4a91397

Browse files
feat: add view transitions
1 parent c4d828c commit 4a91397

File tree

5 files changed

+43
-6
lines changed

5 files changed

+43
-6
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"svelte-exmarkdown": "^5.0.1",
6161
"svelte-meta-tags": "^4.3.0",
6262
"svelte-sonner": "^1.0.3",
63+
"sveltekit-view-transition": "^0.5.3",
6364
"tailwind-merge": "^3.3.0",
6465
"tailwind-variants": "^1.0.0",
6566
"tailwindcss": "^4.1.7",

pnpm-lock.yaml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/routes/+layout.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { ProgressBar } from "@prgm/sveltekit-progress-bar";
88
import { ModeWatcher, resetMode, setMode } from "mode-watcher";
99
import { MetaTags, deepMerge } from "svelte-meta-tags";
10+
import { setupViewTransition } from "sveltekit-view-transition";
1011
import { news } from "$lib/news/news.json";
1112
import type { Entries } from "$lib/types";
1213
import { cn } from "$lib/utils";
@@ -18,6 +19,8 @@
1819
1920
let { data, children } = $props();
2021
22+
setupViewTransition();
23+
2124
// SEO
2225
let metaTags = $derived(deepMerge(data.baseMetaTags, page.data.pageMetaTags));
2326

src/routes/package/[...package]/+page.svelte

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import ReleaseCard from "./ReleaseCard.svelte";
1616
1717
let { data } = $props();
18+
let viewTransitionName = $derived(data.currentPackage.pkg.name.replace(/[@/-]/g, ""));
1819
let latestRelease = $derived(
1920
data.currentPackage.category.slug === ALL_SLUG
2021
? undefined
@@ -100,7 +101,10 @@
100101
{:then}
101102
<div class="flex flex-col">
102103
<div class="my-8">
103-
<h1 class="text-3xl font-semibold text-primary text-shadow-sm md:text-5xl">
104+
<h1
105+
class="text-3xl font-semibold text-primary text-shadow-sm md:text-5xl"
106+
style:view-transition-name="title-{viewTransitionName}"
107+
>
104108
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
105109
{@html data.currentPackage.pkg.name.replace(/\//g, "/<wbr />")}
106110
</h1>
@@ -113,7 +117,11 @@
113117
target="_blank"
114118
class="underline-offset-2 group-hover:underline after:ml-0.5 after:inline-block after:font-sans after:text-sm after:content-['↗']"
115119
>
116-
{data.currentPackage.repoOwner}/<wbr />{data.currentPackage.repoName}
120+
<span style:view-transition-name="owner-{viewTransitionName}">
121+
{data.currentPackage.repoOwner}
122+
</span>/<wbr /><span style:view-transition-name="repo-name-{viewTransitionName}">
123+
{data.currentPackage.repoName}
124+
</span>
117125
</a>
118126
</h2>
119127
<Separator
@@ -153,7 +161,9 @@
153161
</Collapsible.Root>
154162
</div>
155163
{#if data.currentPackage.pkg.description}
156-
<h3 class="mt-4 italic">{data.currentPackage.pkg.description}</h3>
164+
<h3 class="mt-4 italic" style:view-transition-name="desc-{viewTransitionName}">
165+
{data.currentPackage.pkg.description}
166+
</h3>
157167
{/if}
158168
</div>
159169
<Accordion.Root

src/routes/packages/+page.svelte

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<h3 class="font-display text-3xl text-primary text-shadow-sm">{category.name}</h3>
6161
<ul class="mt-2">
6262
{#each packages as { repoOwner, repoName, pkg }, index (pkg.name)}
63+
{@const viewTransitionName = pkg.name.replace(/[@/-]/g, "")}
6364
{@const linkedBadgeData = getBadgeDataFromOther(pkg.name)}
6465
{#if index > 0}
6566
<Separator class="mx-auto my-1 w-[95%]" />
@@ -70,14 +71,22 @@
7071
class="group flex items-center gap-4 rounded-xl px-4 py-3 transition-colors hover:bg-neutral-100 dark:hover:bg-neutral-800"
7172
>
7273
<div class="flex flex-col">
73-
<h4 class="font-medium">{pkg.name}</h4>
74+
<h4 class="font-medium" style:view-transition-name="title-{viewTransitionName}">
75+
{pkg.name}
76+
</h4>
7477
<span class="text-muted-foreground">
75-
{pkg.description}
78+
<span style:view-transition-name="desc-{viewTransitionName}">
79+
{pkg.description}
80+
</span>
7681
<span class="font-bold">
7782
{#if pkg.description}
7883
7984
{/if}
80-
{repoOwner}/{repoName}
85+
<span style:view-transition-name="owner-{viewTransitionName}">
86+
{repoOwner}
87+
</span>/<span style:view-transition-name="repo-name-{viewTransitionName}">
88+
{repoName}
89+
</span>
8190
</span>
8291
</span>
8392
</div>

0 commit comments

Comments
 (0)