Skip to content

Commit 58faa3b

Browse files
Upgrade to Svelte 5 (#35)
1 parent b0e91fd commit 58faa3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1765
-1637
lines changed

components.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://shadcn-svelte.com/schema.json",
2+
"$schema": "https://next.shadcn-svelte.com/schema.json",
33
"style": "default",
44
"tailwind": {
55
"config": "tailwind.config.ts",
@@ -8,6 +8,10 @@
88
},
99
"aliases": {
1010
"components": "$lib/components",
11-
"utils": "$lib/utils"
12-
}
11+
"utils": "$lib/utils",
12+
"ui": "$lib/components/ui",
13+
"hooks": "$lib/hooks"
14+
},
15+
"typescript": true,
16+
"registry": "https://next.shadcn-svelte.com/registry"
1317
}

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,21 @@
1414
},
1515
"devDependencies": {
1616
"@neoconfetti/svelte": "^2.2.1",
17+
"@octokit/graphql-schema": "^15.25.0",
1718
"@shikijs/langs": "^1.25.1",
1819
"@shikijs/rehype": "^1.25.1",
1920
"@shikijs/themes": "^1.25.1",
2021
"@sveltejs/adapter-vercel": "^5.5.2",
2122
"@sveltejs/kit": "^2.15.1",
22-
"@sveltejs/vite-plugin-svelte": "^3.1.2",
23+
"@sveltejs/vite-plugin-svelte": "^4.0.0",
2324
"@tailwindcss/typography": "^0.5.15",
2425
"@total-typescript/ts-reset": "^0.6.1",
2526
"@types/eslint-config-prettier": "^6.11.3",
2627
"@types/semver": "^7.5.8",
2728
"@vercel/speed-insights": "^1.1.0",
2829
"arctic": "^1.9.2",
2930
"autoprefixer": "^10.4.20",
30-
"bits-ui": "^0.22.0",
31+
"bits-ui": "1.0.0-next.74",
3132
"clsx": "^2.1.1",
3233
"eslint": "^9.17.0",
3334
"eslint-config-prettier": "^9.1.0",
@@ -44,16 +45,17 @@
4445
"rehype-raw": "^7.0.0",
4546
"semver": "^7.6.3",
4647
"shiki": "^1.25.1",
47-
"svelte": "^4.2.19",
48+
"svelte": "^5.1.3",
4849
"svelte-check": "^4.1.1",
49-
"svelte-exmarkdown": "^3.0.5",
50-
"svelte-meta-tags": "^3.1.4",
50+
"svelte-exmarkdown": "^4.0.1",
51+
"svelte-meta-tags": "^4.0.4",
5152
"svelte-persisted-store": "^0.12.0",
5253
"svelte-sonner": "^0.3.28",
5354
"sveltekit-search-params": "^3.0.0",
5455
"tailwind-merge": "^2.6.0",
5556
"tailwind-variants": "^0.3.0",
5657
"tailwindcss": "^3.4.17",
58+
"tailwindcss-animate": "^1.0.7",
5759
"tslib": "^2.8.1",
5860
"typescript": "^5.7.2",
5961
"typescript-eslint": "^8.19.0",

pnpm-lock.yaml

Lines changed: 663 additions & 565 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
<script lang="ts">
2-
import { onMount } from "svelte";
2+
import { onMount, type Snippet } from "svelte";
33
import { get } from "svelte/store";
44
import { persisted } from "svelte-persisted-store";
55
import { plainTextSerializer } from "$lib/stores";
66
7-
/**
8-
* The name of the localStorage item to get the date from.
9-
*/
10-
export let storedDateItem: string;
11-
/**
12-
* Whether to show the pulse animation.
13-
*/
14-
export let show = false;
7+
type Props = {
8+
/**
9+
* The name of the localStorage item to get the date from.
10+
*/
11+
storedDateItem: string;
12+
/**
13+
* Whether to show the pulse animation.
14+
*/
15+
show?: boolean;
16+
children?: Snippet;
17+
};
1518
16-
let shouldShowPulse = false;
19+
let { storedDateItem, show = false, children }: Props = $props();
20+
21+
let shouldShowPulse = $state(false);
1722
1823
onMount(() => {
1924
if (!storedDateItem) return;
@@ -30,14 +35,14 @@
3035

3136
{#if show && shouldShowPulse}
3237
<div class="relative inline-flex">
33-
<slot />
38+
{@render children?.()}
3439
<span class="absolute right-0 top-0 -mr-0.5 -mt-0.5 flex size-2.5">
3540
<span
3641
class="absolute inline-flex h-full w-full animate-ping rounded-full bg-primary opacity-75"
37-
/>
38-
<span class="inline-flex size-2.5 rounded-full bg-primary" />
42+
></span>
43+
<span class="inline-flex size-2.5 rounded-full bg-primary"></span>
3944
</span>
4045
</div>
4146
{:else}
42-
<slot />
47+
{@render children?.()}
4348
{/if}

src/lib/components/GHBadge.svelte

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
} from "lucide-svelte";
1313
1414
type CommonStatus = "open" | "closed";
15-
type Props =
15+
type PropsObj =
1616
| {
1717
type: "pull";
1818
status: "draft" | CommonStatus | "merged";
@@ -22,12 +22,16 @@
2222
status: CommonStatus | "solved";
2323
};
2424
25-
export let type: Props["type"];
26-
export let status: Props["status"]; // NOT type-safe for now, waiting for Svelte 5 props declaration
25+
type Props = {
26+
type: PropsObj["type"];
27+
status: PropsObj["status"];
28+
};
2729
28-
let icon: ComponentType<Icon> | null = null;
29-
let label = "";
30-
let color = "";
30+
let { type, status }: Props = $props();
31+
32+
let icon = $state<ComponentType<Icon>>();
33+
let label = $state("");
34+
let color = $state("");
3135
3236
switch (type) {
3337
case "pull":
@@ -77,7 +81,8 @@
7781

7882
<div class="flex items-center rounded-full px-4 py-2 text-white {color}">
7983
{#if icon}
80-
<svelte:component this={icon} class="mr-2 size-5" />
84+
{@const SvelteComponent = icon}
85+
<SvelteComponent class="mr-2 size-5" />
8186
{/if}
8287
<span class="font-semibold">{label}</span>
8388
</div>

src/lib/components/MarkdownRenderer.svelte

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,21 @@
1010
import rehypeRaw from "rehype-raw";
1111
import { cn } from "$lib/utils";
1212
13-
export let markdown: string;
14-
export let inline = false;
15-
export let parseRawHtml = false;
16-
export let additionalPlugins: Plugin[] = [];
13+
type Props = {
14+
markdown: string;
15+
inline?: boolean;
16+
parseRawHtml?: boolean;
17+
additionalPlugins?: Plugin[];
18+
class?: string | undefined | null;
19+
};
1720
18-
let className: string | undefined | null = undefined;
19-
export { className as class };
21+
let {
22+
markdown: md,
23+
inline = false,
24+
parseRawHtml = false,
25+
additionalPlugins = [],
26+
class: className = undefined
27+
}: Props = $props();
2028
</script>
2129

2230
<!-- TODO: actually figure out how to overflow-x-auto the code blocks -->
@@ -30,7 +38,7 @@
3038
)}
3139
>
3240
<Markdown
33-
md={markdown}
41+
{md}
3442
plugins={[
3543
gfmPlugin(),
3644
...(parseRawHtml ? [{ rehypePlugin: rehypeRaw }] : []),

src/lib/components/ScreenSize.svelte

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@
1313
size: parseInt(configScreens[screen as keyof typeof configScreens].replace("px", ""))
1414
}))
1515
.sort((a, b) => a.size - b.size);
16-
let matchingScreen: (typeof screens)[number] | undefined;
17-
$: matchingScreen = screens.findLast(screen => screen.size <= width);
1816
19-
let width = 0;
20-
let height = 0;
17+
let width = $state(0);
18+
let height = $state(0);
2119
22-
let showAllScreens = false;
20+
let matchingScreen = $derived(screens.findLast(screen => screen.size <= width));
21+
let showAllScreens = $state(false);
2322
</script>
2423

2524
<svelte:window bind:innerWidth={width} bind:innerHeight={height} />
@@ -36,7 +35,7 @@
3635
<button
3736
type="button"
3837
class="inline rounded-l-sm rounded-r-full px-1 hover:bg-neutral-500 active:bg-neutral-600"
39-
on:click={() => (showAllScreens = !showAllScreens)}
38+
onclick={() => (showAllScreens = !showAllScreens)}
4039
>
4140
{matchingScreen.name.toUpperCase()}
4241
</button>

src/lib/components/Step.svelte

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
<script lang="ts">
2+
import type { Snippet } from "svelte";
23
import { cn } from "$lib/utils";
34
4-
let className: string | undefined | null = undefined;
5-
export { className as class };
5+
type Props = {
6+
class?: string | undefined | null;
7+
stepIcon?: Snippet;
8+
children?: Snippet;
9+
};
10+
11+
let { class: className = undefined, stepIcon, children }: Props = $props();
612
</script>
713

814
<div class={cn("step relative", className)}>
915
<span
1016
class="absolute -ml-[50px] -mt-0.5 inline-flex size-9 items-center justify-center rounded-full border-4 border-background bg-muted text-center -indent-[1px] font-mono text-base font-normal"
1117
>
12-
{#if $$slots.stepIcon}
13-
<slot name="stepIcon" />
18+
{#if stepIcon}
19+
{@render stepIcon?.()}
1420
{:else}
1521
<span class="[counter-increment:step] before:content-[counter(step)]"></span>
1622
{/if}
1723
</span>
18-
<slot />
24+
{@render children?.()}
1925
</div>

src/lib/components/Steps.svelte

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
<script lang="ts">
2+
import type { Snippet } from "svelte";
23
import { cn } from "$lib/utils";
34
4-
let className: string | undefined | null = undefined;
5-
export { className as class };
5+
type Props = {
6+
class?: string | undefined | null;
7+
children?: Snippet;
8+
[key: string]: unknown;
9+
};
10+
11+
let { class: className = undefined, children, ...rest }: Props = $props();
612
</script>
713

814
<div
915
class={cn("ml-4 border-l pl-8 [counter-reset:step] [&>.step:not(:first-child)]:mt-8", className)}
10-
{...$$restProps}
16+
{...rest}
1117
>
12-
<slot />
18+
{@render children?.()}
1319
</div>
Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
<script lang="ts">
2-
import { page } from "$app/stores";
3-
let data: HTMLParagraphElement | undefined = undefined;
2+
import type { Snippet } from "svelte";
3+
import { page } from "$app/state";
44
5-
const org = $page.data.org;
6-
const repo = $page.data.repo;
5+
type Props = {
6+
children?: Snippet;
7+
};
78
8-
$: if (data) {
9+
let { children }: Props = $props();
10+
let data = $state<HTMLParagraphElement>();
11+
12+
$effect(() => {
13+
if (!data) return;
914
let replaced = data.innerHTML;
1015
const issuesCandidates = replaced.matchAll(/ #(\d+)/g) || [];
1116
for (let candidate of issuesCandidates) {
@@ -14,13 +19,13 @@
1419
if (!wholeMatch || !matchedGroup) continue;
1520
replaced = replaced.replace(
1621
wholeMatch,
17-
` <a href="https://github.com/${org}/${repo}/issues/${matchedGroup}">${wholeMatch.trim()}</a>`
22+
` <a href="https://github.com/${page.data.org}/${page.data.repo}/issues/${matchedGroup}">${wholeMatch.trim()}</a>`
1823
);
1924
}
2025
data.innerHTML = replaced;
21-
}
26+
});
2227
</script>
2328

2429
<p bind:this={data}>
25-
<slot />
30+
{@render children?.()}
2631
</p>

0 commit comments

Comments
 (0)