migrate: convert most components to svelte 5
This commit is contained in:
1 parent
d670f39f0a
commit
10ef4123da
225 files changed
+5441
-3341
No files matched your search
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { preventDefault } from 'svelte/legacy'
|
||||
|
||||
import {
|
||||
ArrowUp,
|
||||
Bookmark,
|
||||
@@ -30,25 +32,38 @@
|
||||
import { expoInOut, expoOut } from 'svelte/easing'
|
||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||
|
||||
export let node: CommentNodeI
|
||||
export let postId: number
|
||||
export let op: boolean = false
|
||||
interface Props {
|
||||
node: CommentNodeI
|
||||
postId: number
|
||||
op?: boolean
|
||||
actions?: boolean
|
||||
meta?: boolean
|
||||
open?: boolean
|
||||
replying?: boolean
|
||||
contentClass?: string
|
||||
class?: string
|
||||
metaSuffix?: import('svelte').Snippet
|
||||
children?: import('svelte').Snippet
|
||||
}
|
||||
|
||||
export let actions: boolean = true
|
||||
export let meta: boolean = true
|
||||
let {
|
||||
node = $bindable(),
|
||||
postId,
|
||||
op = false,
|
||||
actions = true,
|
||||
meta = true,
|
||||
open = $bindable(true),
|
||||
replying = $bindable(false),
|
||||
contentClass = '',
|
||||
class: clazz = '',
|
||||
metaSuffix,
|
||||
children,
|
||||
}: Props = $props()
|
||||
|
||||
export let open = true
|
||||
let editing = $state(false)
|
||||
let newComment = $state(node.comment_view.comment.content)
|
||||
|
||||
export let replying = false
|
||||
|
||||
let editing = false
|
||||
let newComment = node.comment_view.comment.content
|
||||
|
||||
let editingLoad = false
|
||||
|
||||
export let contentClass: string = ''
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
let editingLoad = $state(false)
|
||||
|
||||
async function save() {
|
||||
if (!$profile?.jwt || newComment.length <= 0) return
|
||||
@@ -84,13 +99,15 @@
|
||||
}
|
||||
})
|
||||
|
||||
let highlight = ''
|
||||
let highlight = $state('')
|
||||
</script>
|
||||
|
||||
{#if editing}
|
||||
<Modal bind:open={editing}>
|
||||
<span slot="title">{$t('form.edit')}</span>
|
||||
<form on:submit|preventDefault={save} class="contents">
|
||||
{#snippet customTitle()}
|
||||
<span>{$t('form.edit')}</span>
|
||||
{/snippet}
|
||||
<form onsubmit={preventDefault(save)} class="contents">
|
||||
<CommentForm
|
||||
postId={node.comment_view.comment.id}
|
||||
bind:value={newComment}
|
||||
@@ -120,11 +137,11 @@
|
||||
>
|
||||
{#if meta}
|
||||
<button
|
||||
on:click={() => (open = !open)}
|
||||
onclick={() => (open = !open)}
|
||||
class="flex flex-row cursor-pointer gap-2 items-center group text-[13px] flex-wrap w-full
|
||||
z-0 group relative"
|
||||
>
|
||||
<slot name="meta-suffix" />
|
||||
{@render metaSuffix?.()}
|
||||
<div
|
||||
class="absolute opacity-0 -z-10 inset-0 group-hover:block group-hover:opacity-100
|
||||
bg-slate-100 dark:bg-zinc-900 group-hover:-inset-1 group-hover:-inset-x-2 rounded-full transition-all
|
||||
@@ -154,14 +171,14 @@
|
||||
avatar
|
||||
user={node.comment_view.creator}
|
||||
>
|
||||
<svelte:fragment slot="badges">
|
||||
{#snippet extraBadges()}
|
||||
{#if node.comment_view.creator_is_moderator}
|
||||
<ShieldIcon filled width={14} class="text-green-500" />
|
||||
{/if}
|
||||
{#if node.comment_view.creator_is_admin}
|
||||
<ShieldIcon filled width={14} class="text-red-500" />
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
{/snippet}
|
||||
</UserLink>
|
||||
{#if op}
|
||||
<Icon mini size="16" src={Microphone} class="text-sky-600" />
|
||||
@@ -254,7 +271,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
<div class="bg-transparent dark:bg-transparent">
|
||||
<slot />
|
||||
{@render children?.()}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
Reference in new issue
Block a user