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

+27 -20
View File
@@ -1,4 +1,4 @@
<script lang="ts" context="module">
<script lang="ts" module>
import { pushState } from '$app/navigation'
export function showImage(url: string, alt: string = '') {
@@ -24,13 +24,8 @@
import { focusTrap } from 'svelte-focus-trap'
import { t } from '$lib/translations'
/**
* The full-resolution image URL
*/
export let alt: string = ''
let zoomed = false
let sharing = false
let zoomed = $state(false)
let sharing = $state(false)
async function downloadImage(url: string) {
sharing = true
@@ -43,21 +38,29 @@
sharing = false
return file
}
let clazz: string = ''
export { clazz as class }
interface Props {
/**
* The full-resolution image URL
*/
alt?: string
class?: string
children?: import('svelte').Snippet
}
let { alt = '', class: clazz = '', children }: Props = $props()
</script>
{#if $page.state.openImage || '' != ''}
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-positive-tabindex -->
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_positive_tabindex -->
<div
class="fixed top-0 left-0 w-screen h-[100svh] overflow-auto bg-white/50 dark:bg-black/50
flex flex-col z-[100] backdrop-blur-sm"
transition:fade={{ duration: 150 }}
on:click={() => history.back()}
on:keydown={(e) => {
onclick={() => history.back()}
onkeydown={(e) => {
if (e.key == 'Escape') history.back()
}}
use:focusTrap
@@ -117,7 +120,9 @@
title={$t('post.actions.more.share')}
loading={sharing}
>
<Icon src={Share} size="20" micro slot="prefix" />
{#snippet prefix()}
<Icon src={Share} size="20" micro />
{/snippet}
</Button>
<Button
on:click={() => {
@@ -141,13 +146,15 @@
rounding="pill"
title={$t('post.image.close')}
>
<Icon src={XMark} size="20" micro slot="prefix" />
{#snippet prefix()}
<Icon src={XMark} size="20" micro />
{/snippet}
</Button>
</Material>
</div>
</div>
{/if}
<button on:click={() => history.back()} class="contents {clazz}">
<slot />
<button onclick={() => history.back()} class="contents {clazz}">
{@render children?.()}
</button>