Skip to content

Commit

Permalink
runs svelte 5 migration assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
stolinski committed Oct 21, 2024
1 parent ba9158f commit cb36faf
Show file tree
Hide file tree
Showing 96 changed files with 1,213 additions and 712 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.11.1",
"@playwright/test": "^1.46.0",
"@sveltejs/kit": "^2.5.22",
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"@sveltejs/kit": "^2.5.27",
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"@types/chroma-js": "^2.4.4",
"@types/js-cookie": "^3.0.6",
"@types/node": "^22.2.0",
Expand All @@ -44,7 +44,7 @@
"dotenv": "^16.4.5",
"eslint": "^9.9.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.43.0",
"eslint-plugin-svelte": "^2.45.1",
"globals": "^15.10.0",
"mysql2": "^3.11.0",
"postcss": "^8.4.41",
Expand All @@ -60,12 +60,12 @@
"stylelint": "^16.9.0",
"stylelint-config-standard": "^36.0.1",
"stylelint-declaration-strict-value": "^1.10.6",
"svelte": "^4.2.18",
"svelte-check": "^3.8.5",
"svelte": "^5.0.0",
"svelte-check": "^4.0.0",
"svelte-preprocess": "^6.0.2",
"tslib": "^2.6.3",
"typescript": "^5.5.4",
"vite": "^5.4.0",
"vite": "^5.4.4",
"vitest": "^2.0.5"
},
"type": "module",
Expand Down
661 changes: 349 additions & 312 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion src/lib/AdminActions.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<script>
/**
* @typedef {Object} Props
* @property {import('svelte').Snippet} [children]
*/
/** @type {Props} */
let { children } = $props();
</script>

<div class="flex">
<slot />
{@render children?.()}
</div>

<style>
Expand Down
6 changes: 5 additions & 1 deletion src/lib/AdminSearch.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<script lang="ts">
export let text = '';
interface Props {
text?: string;
}
let { text = $bindable('') }: Props = $props();
</script>

<input type="text" bind:value={text} placeholder="Search" />
Expand Down
18 changes: 11 additions & 7 deletions src/lib/ComponentWindow.svelte
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
<script lang="ts">
import type { SvelteComponent } from 'svelte';
export let Component: typeof SvelteComponent;
interface Props {
Component: typeof SvelteComponent;
}
let { Component }: Props = $props();
let window_width;
let window_width = $state();
</script>

<h4>NewsletterForm</h4>

<div class="window" bind:clientWidth={window_width}>
<span>{window_width}</span>
<svelte:component this={Component} />
<Component />
</div>

<div class="layout full">
<div class="main">
<svelte:component this={Component} />
<Component />
</div>
<div class="sidebar">
<svelte:component this={Component} />
<Component />
</div>
<div class="content">
<svelte:component this={Component} />
<Component />
</div>
<div class="full zone" style:--bg="var(--black)" style:--fg="var(--white)">
<svelte:component this={Component} />
<Component />
</div>
</div>

Expand Down
1 change: 1 addition & 0 deletions src/lib/DropdownMenu.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- @migration-task Error while migrating Svelte code: This migration would change the name of a slot making the component unusable -->
<script lang="ts">
// ? What is this
// A popover based drop down menu. Less specific than the Select Menu
Expand Down
8 changes: 6 additions & 2 deletions src/lib/FacePile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
name: string;
github: string;
};
export let size = '50px';
export let faces: FaceForThePile[] = [];
interface Props {
size?: string;
faces?: FaceForThePile[];
}
let { size = '50px', faces = [] }: Props = $props();
</script>

<div class="pile" style:--face-size={size} style:--face-count={faces.length}>
Expand Down
20 changes: 15 additions & 5 deletions src/lib/FormButton.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
<script lang="ts">
import { enhance } from '$app/forms';
import { form_action } from './form_action';
export let text: string;
export let thinking_text: string;
export let action_path: string;
interface Props {
text: string;
thinking_text: string;
action_path: string;
children?: import('svelte').Snippet;
}
let thinking = false;
let {
text,
thinking_text,
action_path,
children
}: Props = $props();
let thinking = $state(false);
</script>

<form
Expand All @@ -21,6 +31,6 @@
}
)}
>
<slot />
{@render children?.()}
<button disabled={thinking} type="submit">{thinking ? thinking_text : text}</button>
</form>
16 changes: 11 additions & 5 deletions src/lib/FormWithLoader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
import { loading } from '$state/loading';
import type { ActionResult, SubmitFunction } from '@sveltejs/kit';
import toast from 'svelte-french-toast';
let formLoading = false;
export let global = true; // By default, the global loader UI is used
export let confirm = '';
let formLoading = $state(false);
interface Props {
global?: boolean;
confirm?: string;
children?: import('svelte').Snippet<[any]>;
[key: string]: any
}
let { global = true, confirm = '', children, ...rest }: Props = $props();
type FormActionMessage = {
message?: string;
Expand Down Expand Up @@ -48,6 +54,6 @@
};
</script>

<form {...$$restProps} use:enhance={form_action()}>
<slot loading={formLoading} />
<form {...rest} use:enhance={form_action()}>
{@render children?.({ loading: formLoading, })}
</form>
10 changes: 7 additions & 3 deletions src/lib/HostsAndGuests.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<script lang="ts">
import type { Guest } from '@prisma/client';
import Host from '$lib/hosts/Host.svelte';
export let guests: { Guest: Guest }[] = [];
export let hosts: {
interface Props {
guests?: { Guest: Guest }[];
hosts?: {
name: string | null;
username: string | null;
twitter: string | null;
}[] = [];
}[];
}
let { guests = [], hosts = [] }: Props = $props();
</script>

<div class="guests-and-hosts">
Expand Down
12 changes: 8 additions & 4 deletions src/lib/Icon.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script lang="ts" context="module">
<script lang="ts" module>
export type IconName =
| 'play'
| 'playing'
Expand Down Expand Up @@ -36,9 +36,13 @@
<script lang="ts">
import { capitalize } from '$utilities/capitalize';
export let name: IconName;
export let title: string | boolean = '';
export let aria_hidden = true;
interface Props {
name: IconName;
title?: string | boolean;
aria_hidden?: boolean;
}
let { name, title = $bindable(''), aria_hidden = true }: Props = $props();
if (!title && title !== false) title = capitalize(name);
</script>

Expand Down
6 changes: 5 additions & 1 deletion src/lib/ListenLinks.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<script lang="ts">
import type { LatestShow } from '$server/ai/queries';
import Icon from './Icon.svelte';
export let show: LatestShow;
interface Props {
show: LatestShow;
}
let { show }: Props = $props();
</script>

<a
Expand Down
6 changes: 5 additions & 1 deletion src/lib/Logo.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<script lang="ts">
export let height: number | string = '100%';
interface Props {
height?: number | string;
}
let { height = '100%' }: Props = $props();
</script>

<svg {height} viewBox="0 0 1371 1212" fill="none" xmlns="http://www.w3.org/2000/svg">
Expand Down
18 changes: 11 additions & 7 deletions src/lib/Pagination.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@
import { PER_PAGE } from '$const';
import { quintOut } from 'svelte/easing';
import { fade } from 'svelte/transition';
export let count: number;
export let perPage: number = PER_PAGE;
export let page: number = 1;
$: totalPages = Math.ceil(count / perPage);
$: generate_search_params = (id: string, value: string | number) => {
interface Props {
count: number;
perPage?: number;
page?: number;
}
let { count, perPage = PER_PAGE, page = 1 }: Props = $props();
let totalPages = $derived(Math.ceil(count / perPage));
let generate_search_params = $derived((id: string, value: string | number) => {
const searchParams = new URLSearchParams($pageStore.url.search);
if (!value) {
searchParams.delete(id);
} else {
searchParams.set(id, value.toString());
}
return searchParams.toString();
};
});
function getNeighboringNumbers(number: number, maxNumber: number): number[] {
const start: number = Math.max(1, number - 3);
const end: number = Math.min(maxNumber, number + 3);
Expand All @@ -26,7 +30,7 @@
return result;
}
$: pageNumbers = getNeighboringNumbers(page, totalPages);
let pageNumbers = $derived(getNeighboringNumbers(page, totalPages));
</script>

<div class="pagination">
Expand Down
27 changes: 19 additions & 8 deletions src/lib/SelectMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,35 @@
apply();
}
export let options: { value: string; label: string }[];
export let button_icon: IconName | null = null;
export let value_as_label: boolean = false;
export let button_text: string;
export let popover_id: string;
let id = popover_id.replace('filter-', '');
export let value: string = '';
interface Props {
options: { value: string; label: string }[];
button_icon?: IconName | null;
value_as_label?: boolean;
button_text: string;
popover_id: string;
value?: string;
}
let {
options,
button_icon = null,
value_as_label = false,
button_text,
popover_id,
value = ''
}: Props = $props();
// let searchParams = new URLSearchParams(window.location.search);
$: generate_search_params = (id: string, value: string) => {
let generate_search_params = $derived((id: string, value: string) => {
const searchParams = new URLSearchParams($page.url.search);
if (!value) {
searchParams.delete(id);
} else {
searchParams.set(id, value);
}
return searchParams.toString();
};
});
function closePopoverWhenSelected(node: HTMLDivElement) {
function handlePopoverSelection(event: MouseEvent) {
Expand Down
25 changes: 18 additions & 7 deletions src/lib/ShowCard.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script lang="ts">
import { preventDefault } from 'svelte/legacy';
import { player } from '$state/player';
import { format_show_type } from '$utilities/format_show_type';
import get_show_path from '$utilities/slug';
Expand All @@ -9,10 +11,19 @@
import Badges from './badges/Badges.svelte';
import type { ShowCard } from '$/server/shows/shows_queries';
export let show: ShowCard;
export let display: 'list' | 'card' | 'highlight' = 'card';
export let heading = 'h4';
export let show_date = new Date(show.date);
interface Props {
show: ShowCard;
display?: 'list' | 'card' | 'highlight';
heading?: string;
show_date?: any;
}
let {
show,
display = 'card',
heading = 'h4',
show_date = new Date(show.date)
}: Props = $props();
function format_date(date: Date, baseDate: Date = new Date()) {
const timeFormatter = new Intl.RelativeTimeFormat('en', { numeric: 'auto' });
Expand All @@ -34,7 +45,7 @@
let hosts: {
name: string;
github: string;
}[] = [];
}[] = $state([]);
if ((show?.hosts?.length || 0) > 0) {
show.hosts?.forEach((host) => {
hosts.push({
Expand All @@ -59,7 +70,7 @@
{#if display === 'list'}
<button
data-testid="play-show"
on:click|preventDefault={() => player.start_show(show)}
onclick={preventDefault(() => player.start_show(show))}
class="play-button"
>
<Icon name="play" />
Expand Down Expand Up @@ -124,7 +135,7 @@
<button
data-testid="play-show"
class:play={display === 'highlight'}
on:click|preventDefault={() => player.start_show(show)}
onclick={preventDefault(() => player.start_show(show))}
><Icon name="play" /> Play #{show.number}</button
>
</div>
Expand Down
Loading

0 comments on commit cb36faf

Please sign in to comment.