Skip to content

Commit c563339

Browse files
Initial migration
Basically script, generics and basic errors adjustments
1 parent b05665a commit c563339

File tree

15 files changed

+677
-514
lines changed

15 files changed

+677
-514
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@shikijs/rehype": "^1.22.0",
1818
"@sveltejs/adapter-vercel": "^5.4.5",
1919
"@sveltejs/kit": "^2.7.1",
20-
"@sveltejs/vite-plugin-svelte": "^3.1.2",
20+
"@sveltejs/vite-plugin-svelte": "^4.0.0",
2121
"@tailwindcss/typography": "^0.5.15",
2222
"@total-typescript/ts-reset": "^0.6.1",
2323
"@types/eslint-config-prettier": "^6.11.3",
@@ -42,7 +42,7 @@
4242
"rehype-raw": "^7.0.0",
4343
"semver": "^7.6.3",
4444
"shiki": "^1.22.0",
45-
"svelte": "^4.2.19",
45+
"svelte": "^5.0.0",
4646
"svelte-check": "^4.0.5",
4747
"svelte-exmarkdown": "^3.0.5",
4848
"svelte-meta-tags": "^3.1.4",

pnpm-lock.yaml

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

src/lib/components/BlinkingBadge.svelte

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,21 @@
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?: import("svelte").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+
}
29+
30+
let { type, status }: Props = $props();
2731
28-
let icon: ComponentType<Icon> | null = null;
29-
let label = "";
30-
let color = "";
32+
let icon = $state<ComponentType<Icon> | null>(null);
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: 14 additions & 6 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,
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 -->

src/lib/components/ScreenSize.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
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);
16+
let matchingScreen: (typeof screens)[number] | undefined = $derived(screens.findLast(screen => screen.size <= width));
1817
19-
let width = 0;
20-
let height = 0;
18+
let width = $state(0);
19+
let height = $state(0);
2120
22-
let showAllScreens = false;
21+
let showAllScreens = $state(false);
22+
2323
</script>
2424

2525
<svelte:window bind:innerWidth={width} bind:innerHeight={height} />
@@ -36,7 +36,7 @@
3636
<button
3737
type="button"
3838
class="inline rounded-l-sm rounded-r-full px-1 hover:bg-neutral-500 active:bg-neutral-600"
39-
on:click={() => (showAllScreens = !showAllScreens)}
39+
onclick={() => (showAllScreens = !showAllScreens)}
4040
>
4141
{matchingScreen.name.toUpperCase()}
4242
</button>

src/lib/components/Step.svelte

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

813
<div class={cn("step relative", className)}>
914
<span
1015
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"
1116
>
12-
{#if $$slots.stepIcon}
13-
<slot name="stepIcon" />
17+
{#if stepIcon}
18+
{@render stepIcon?.()}
1419
{:else}
1520
<span class="[counter-increment:step] before:content-[counter(step)]"></span>
1621
{/if}
1722
</span>
18-
<slot />
23+
{@render children?.()}
1924
</div>

src/lib/components/Steps.svelte

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

813
<div
914
class={cn("ml-4 border-l pl-8 [counter-reset:step] [&>.step:not(:first-child)]:mt-8", className)}
10-
{...$$restProps}
15+
{...rest}
1116
>
12-
<slot />
17+
{@render children?.()}
1318
</div>
Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
<script lang="ts">
2+
import { run } from "svelte/legacy";
3+
24
import { page } from "$app/stores";
3-
let data: HTMLParagraphElement | undefined = undefined;
5+
type Props = {
6+
children?: import("svelte").Snippet;
7+
};
8+
9+
let { children }: Props = $props();
10+
let data = $state<HTMLParagraphElement>();
411
512
const org = $page.data.org;
613
const repo = $page.data.repo;
714
8-
$: if (data) {
9-
let replaced = data.innerHTML;
10-
const issuesCandidates = replaced.matchAll(/ #(\d+)/g) || [];
11-
for (let candidate of issuesCandidates) {
12-
const wholeMatch = candidate[0];
13-
const matchedGroup = candidate[1];
14-
if (!wholeMatch || !matchedGroup) continue;
15-
replaced = replaced.replace(
16-
wholeMatch,
17-
` <a href="https://github.com/${org}/${repo}/issues/${matchedGroup}">${wholeMatch.trim()}</a>`
18-
);
15+
run(() => {
16+
if (data) {
17+
let replaced = data.innerHTML;
18+
const issuesCandidates = replaced.matchAll(/ #(\d+)/g) || [];
19+
for (let candidate of issuesCandidates) {
20+
const wholeMatch = candidate[0];
21+
const matchedGroup = candidate[1];
22+
if (!wholeMatch || !matchedGroup) continue;
23+
replaced = replaced.replace(
24+
wholeMatch,
25+
` <a href="https://github.com/${org}/${repo}/issues/${matchedGroup}">${wholeMatch.trim()}</a>`
26+
);
27+
}
28+
data.innerHTML = replaced;
1929
}
20-
data.innerHTML = replaced;
21-
}
30+
});
2231
</script>
2332

2433
<p bind:this={data}>
25-
<slot />
34+
{@render children?.()}
2635
</p>

src/lib/components/renderers/ListElementRenderer.svelte

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
11
<script lang="ts">
2+
import { run } from "svelte/legacy";
3+
24
import { ArrowRight } from "lucide-svelte";
35
import { Button } from "$lib/components/ui/button";
6+
type Props = {
7+
children?: import("svelte").Snippet;
8+
};
9+
10+
let { children }: Props = $props();
411
5-
let data: HTMLLIElement | undefined = undefined;
12+
let data = $state<HTMLLIElement>();
613
let pullsLinks: string[] = [];
714
let issuesLinks: string[] = [];
8-
let allLinks: string[] = [];
15+
let allLinks = $state<string[]>([]);
916
10-
$: if (data) {
11-
const links = data.innerHTML.match(/https?:\/\/[^"]+/g) || [];
12-
for (const link of links) {
13-
if (link.includes("/pull/")) {
14-
pullsLinks.push(link);
15-
} else if (link.includes("/issues/")) {
16-
issuesLinks.push(link);
17+
run(() => {
18+
if (data) {
19+
const links = data.innerHTML.match(/https?:\/\/[^"]+/g) || [];
20+
for (const link of links) {
21+
if (link.includes("/pull/")) {
22+
pullsLinks.push(link);
23+
} else if (link.includes("/issues/")) {
24+
issuesLinks.push(link);
25+
}
1726
}
27+
allLinks = [...pullsLinks, ...issuesLinks];
1828
}
19-
allLinks = [...pullsLinks, ...issuesLinks];
20-
}
29+
});
2130
2231
/**
2332
* Replaces a link with `https://github.com/username/repo/[pull|issues]/123`
@@ -39,7 +48,7 @@
3948
class:font-semibold={data?.innerText.startsWith("breaking:")}
4049
class="group *:inline"
4150
>
42-
<slot />
51+
{@render children?.()}
4352
{#if allLinks.length > 0}
4453
<Button
4554
href={ghLinkToHref(allLinks[0] ?? "")}

0 commit comments

Comments
 (0)