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

@@ -7,11 +7,21 @@
import { Icon, XCircle } from 'svelte-hero-icons'
import { fly } from 'svelte/transition'
export let q: string = ''
interface Props {
q?: string
instance?: string | undefined
listing_type?: ListingType
showWhenEmpty?: boolean
[key: string]: any
}
export let instance: string | undefined = undefined
export let listing_type: ListingType = 'Subscribed'
export let showWhenEmpty: boolean = false
let {
q = $bindable(''),
instance = undefined,
listing_type = 'Subscribed',
showWhenEmpty = false,
...rest
}: Props = $props()
const dispatcher = createEventDispatcher<{ select: Person | undefined }>()
</script>
@@ -32,31 +42,33 @@
on:select
bind:query={q}
{showWhenEmpty}
{...$$restProps}
let:item
let:select
{...rest}
>
<div class="w-full h-full" slot="noresults">
{#if showWhenEmpty}
<MenuButton on:click={() => dispatcher('select', undefined)}>
<Icon src={XCircle} size="16" mini />
{#snippet noresults()}
<div class="w-full h-full">
{#if showWhenEmpty}
<MenuButton on:click={() => dispatcher('select', undefined)}>
<Icon src={XCircle} size="16" mini />
<div class="flex flex-col text-left">
<span>None</span>
</div>
</MenuButton>
{:else}
<span class="mx-auto my-auto">No results.</span>
{/if}
</div>
{/snippet}
{#snippet children({ item, select })}
<div in:fly|global={{ y: -4, opacity: 0 }}>
<MenuButton on:click={() => select(item)}>
<Avatar url={item.avatar} alt={item.name} width={24} />
<div class="flex flex-col text-left">
<span>None</span>
<span>{item.name}</span>
<span class="text-xs opacity-80">
{new URL(item.actor_id).hostname}
</span>
</div>
</MenuButton>
{:else}
<span class="mx-auto my-auto">No results.</span>
{/if}
</div>
<div in:fly|global={{ y: -4, opacity: 0 }}>
<MenuButton on:click={() => select(item)}>
<Avatar url={item.avatar} alt={item.name} width={24} />
<div class="flex flex-col text-left">
<span>{item.name}</span>
<span class="text-xs opacity-80">
{new URL(item.actor_id).hostname}
</span>
</div>
</MenuButton>
</div>
</div>
{/snippet}
</Search>