migrate: convert most components to svelte 5

This commit is contained in:
Xylight committed 2024-10-25 19:33:27 -07:00
1 parent d670f39f0a
commit 10ef4123da
225 files changed
+5441 -3341

No files matched your search

+15 -11
View File
@@ -1,4 +1,6 @@
<script lang="ts">
import { preventDefault } from 'svelte/legacy';
import { navigating, page } from '$app/stores'
import {
GlobeAmericas,
@@ -29,22 +31,22 @@
import { fly } from 'svelte/transition'
import { backOut, expoOut } from 'svelte/easing'
export let data
let { data } = $props();
let search = data.query || ''
let searchElement: HTMLInputElement
let search = $state(data.query || '')
let searchElement: HTMLInputElement = $state()
let instance = ''
let virtualList: HTMLDivElement
let offset: number = 0
let virtualList: HTMLDivElement = $state()
let offset: number = $state(0)
$: showTop =
(data.query ?? '' != '') && data.communities.length > 0 && data.page == 1
let showTop =
$derived((data.query ?? '' != '') && data.communities.length > 0 && data.page == 1)
</script>
<svelte:window
bind:scrollY={offset}
on:keydown={(e) => {
onkeydown={(e) => {
if (e.target == document.body) searchElement?.focus()
}}
/>
@@ -62,8 +64,8 @@
>
<Tabs routes={[]} class="p-2 dark:bg-zinc-925/70 shadow-md shadow-black/5">
<form
on:submit|preventDefault={() =>
searchParam($page.url, 'q', search, 'page')}
onsubmit={preventDefault(() =>
searchParam($page.url, 'q', search, 'page'))}
class="flex gap-2 flex-row items-center w-full text-base h-10"
>
<TextInput
@@ -83,7 +85,9 @@
rounding="pill"
loading={$navigating != null}
>
<Icon src={MagnifyingGlass} size="16" micro slot="prefix" />
{#snippet prefix()}
<Icon src={MagnifyingGlass} size="16" micro />
{/snippet}
</Button>
</form>
</Tabs>
+8 -3
View File
@@ -4,9 +4,14 @@
import { profile } from '$lib/auth.js'
import { toast } from 'mono-svelte'
export let community: CommunityView | undefined = undefined
interface Props {
community?: CommunityView | undefined;
children?: import('svelte').Snippet<[any]>;
}
let subscribing = false
let { community = undefined, children }: Props = $props();
let subscribing = $state(false)
async function subscribe(
id: number | undefined = community?.community.id,
@@ -33,4 +38,4 @@
}
</script>
<slot {subscribe} {subscribing} />
{@render children?.({ subscribe, subscribing, })}