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

@@ -12,14 +12,25 @@
import { t } from '$lib/translations'
import type { View } from '$lib/settings'
export let url: string
export let thumbnail_url: string | undefined = undefined
export let nsfw: boolean = false
export let embed_title: string | undefined = undefined
export let embed_description: string | undefined = undefined
export let view: View = 'cozy'
interface Props {
url: string
thumbnail_url?: string | undefined
nsfw?: boolean
embed_title?: string | undefined
embed_description?: string | undefined
view?: View
}
$: richURL = parseURL(url)
let {
url,
thumbnail_url = undefined,
nsfw = false,
embed_title = undefined,
embed_description = undefined,
view = 'cozy',
}: Props = $props()
let richURL = $derived(parseURL(url))
</script>
<!--
@@ -105,37 +116,39 @@
rounded-full flex p-1 relative -top-7 min-[384px]:mx-3 mt-8 min-[384px]:mt-0 mx-auto -mb-7 w-max max-w-full overflow-auto"
>
<PostLinkSources {url}>
<Button
color="tertiary"
slot="target"
size="sm"
class="w-max text-slate-600 dark:text-zinc-400 block
text-xs flex-shrink-0"
rounding="pill"
>
<Icon src={LinkIcon} size="16" micro class="flex-shrink-0" />
{$t('post.actions.link.actions')}
</Button>
{#snippet target()}
<Button
color="tertiary"
size="sm"
class="w-max text-slate-600 dark:text-zinc-400 block
text-xs flex-shrink-0"
rounding="pill"
>
<Icon src={LinkIcon} size="16" micro class="flex-shrink-0" />
{$t('post.actions.link.actions')}
</Button>
{/snippet}
</PostLinkSources>
</div>
{:else}
<div class="flex space-x-1">
<PostLinkSources {url}>
<Button
color="ghost"
slot="target"
size="xs"
rounding="pill"
class="p-0.5 px-1 w-max mt-auto text-slate-600 dark:text-zinc-400 block
text-xs"
>
<div class="mr-0.5" style="width: 8px;">
<Icon src={LinkIcon} size="16" micro />
</div>
<div class="mr-1" style="width: 8px;">
<Icon src={ChevronDown} size="16" micro />
</div>
</Button>
{#snippet target()}
<Button
color="ghost"
size="xs"
rounding="pill"
class="p-0.5 px-1 w-max mt-auto text-slate-600 dark:text-zinc-400 block
text-xs"
>
<div class="mr-0.5" style="width: 8px;">
<Icon src={LinkIcon} size="16" micro />
</div>
<div class="mr-1" style="width: 8px;">
<Icon src={ChevronDown} size="16" micro />
</div>
</Button>
{/snippet}
</PostLinkSources>
<Button
href={url}
@@ -1,4 +1,4 @@
<script lang="ts" context="module">
<script lang="ts" module>
const sources: {
getLink: (url: string) => string
name: string
@@ -43,12 +43,20 @@
import type { MediaType } from '../helpers'
import { Icon, Share } from 'svelte-hero-icons'
export let url: string
export let type: MediaType = 'embed'
interface Props {
url: string
type?: MediaType
target?: import('svelte').Snippet
[key: string]: any
}
let { url, type = 'embed', target, ...rest }: Props = $props()
</script>
<Menu {...$$restProps}>
<slot name="target" slot="target" />
<Menu {...rest}>
{#snippet target()}
{@render target?.()}
{/snippet}
<MenuDivider>{$t('post.actions.link.title')}</MenuDivider>
{#each sources as source}
@@ -66,7 +74,9 @@
toast({ content: $t('toast.copied') })
}}
>
<Icon src={Share} size="16" micro slot="prefix" />
{#snippet prefix()}
<Icon src={Share} size="16" micro />
{/snippet}
{$t('post.actions.more.share')}
</MenuButton>
</Menu>