migrate: switch to svelte 5 events system for inputs
This commit is contained in:
1 parent
6f442eceab
commit
43a857ed66
11 files changed
+99
-98
No files matched your search
@@ -112,7 +112,7 @@
|
||||
value={newComment}
|
||||
actions={false}
|
||||
preview={true}
|
||||
on:confirm={save}
|
||||
onconfirm={save}
|
||||
/>
|
||||
<Button
|
||||
submit
|
||||
@@ -252,18 +252,18 @@
|
||||
label={$t('comment.reply')}
|
||||
{postId}
|
||||
parentId={node.comment_view.comment.id}
|
||||
on:comment={(e) => {
|
||||
oncomment={(e) => {
|
||||
node.children = [
|
||||
{
|
||||
children: [],
|
||||
comment_view: e.detail.comment_view,
|
||||
comment_view: e.comment_view,
|
||||
depth: node.depth + 1,
|
||||
},
|
||||
...node.children,
|
||||
]
|
||||
replying = false
|
||||
}}
|
||||
on:cancel={() => (replying = false)}
|
||||
oncancel={() => (replying = false)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -12,12 +12,6 @@
|
||||
import { errorMessage } from '$lib/lemmy/error'
|
||||
import { Icon, XMark } from 'svelte-hero-icons'
|
||||
|
||||
const dispatch = createEventDispatcher<{
|
||||
comment: CommentResponse
|
||||
confirm: string
|
||||
cancel: boolean
|
||||
}>()
|
||||
|
||||
interface Props {
|
||||
postId: number
|
||||
parentId?: number | undefined
|
||||
@@ -28,6 +22,9 @@
|
||||
value?: string
|
||||
actions?: boolean
|
||||
preview?: boolean
|
||||
oncomment?: (comment: CommentResponse) => void
|
||||
onconfirm?: (value: string) => void
|
||||
oncancel?: (cancel: boolean) => void
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
@@ -41,6 +38,9 @@
|
||||
value = $bindable(''),
|
||||
actions = true,
|
||||
preview: previewAction = true,
|
||||
oncancel,
|
||||
oncomment,
|
||||
onconfirm,
|
||||
...rest
|
||||
}: Props = $props()
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
post_id: postId,
|
||||
parent_id: parentId,
|
||||
})
|
||||
dispatch('comment', response)
|
||||
oncomment?.(response)
|
||||
|
||||
value = ''
|
||||
} catch (err) {
|
||||
@@ -92,13 +92,12 @@
|
||||
: (placeholder ?? placeholders.get('comment'))}
|
||||
bind:value
|
||||
disabled={locked || loading || banned}
|
||||
on:confirm={() => {
|
||||
onconfirm={() => {
|
||||
if (actions) {
|
||||
submit()
|
||||
dispatch('confirm', value)
|
||||
onconfirm?.(value)
|
||||
}
|
||||
}}
|
||||
on:focus
|
||||
previewButton={previewAction}
|
||||
>
|
||||
<div class="flex-1"></div>
|
||||
@@ -106,19 +105,26 @@
|
||||
<Button
|
||||
size="custom"
|
||||
title={$t('common.cancel')}
|
||||
onclick={() => dispatch('cancel', true)}
|
||||
onclick={() => oncancel?.(true)}
|
||||
color="tertiary"
|
||||
class="w-8 h-8"
|
||||
rounding="xl"
|
||||
rounding="pill"
|
||||
>
|
||||
<Icon src={XMark} size="16" micro />
|
||||
<Icon
|
||||
src={XMark}
|
||||
size="20"
|
||||
micro
|
||||
class="text-slate-600 dark:text-zinc-400"
|
||||
/>
|
||||
</Button>
|
||||
<Button
|
||||
onclick={submit}
|
||||
color="primary"
|
||||
rounding="pill"
|
||||
size="sm"
|
||||
class="py-2 px-4"
|
||||
{loading}
|
||||
disabled={locked || loading || banned}
|
||||
size="lg"
|
||||
>
|
||||
{$t('form.submit')}
|
||||
</Button>
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
required
|
||||
label={$t('form.name')}
|
||||
bind:value={formData.name}
|
||||
on:input={() => {
|
||||
oninput={() => {
|
||||
formData.name = formData.name.toLowerCase().replaceAll(' ', '_')
|
||||
}}
|
||||
disabled={edit != undefined}
|
||||
|
||||
@@ -32,9 +32,7 @@
|
||||
</script>
|
||||
|
||||
<ul
|
||||
class="flex flex-col list-none {settings.view == 'card'
|
||||
? 'gap-3 md:gap-4'
|
||||
: 'divide-y'} divide-slate-200 dark:divide-zinc-800"
|
||||
class="flex flex-col list-none divide-y divide-slate-200 dark:divide-zinc-800"
|
||||
>
|
||||
{#if posts?.length == 0}
|
||||
<div class="h-full grid place-items-center">
|
||||
@@ -63,7 +61,7 @@
|
||||
: settings.view}
|
||||
{post}
|
||||
class="transition-all duration-250"
|
||||
on:hide={() => {
|
||||
onhide={() => {
|
||||
posts = posts.toSpliced(index, 1)
|
||||
}}
|
||||
>
|
||||
@@ -100,10 +98,7 @@
|
||||
easing: expoOut,
|
||||
}}
|
||||
>
|
||||
<span
|
||||
class="text-sm flex flex-row gap-2 items-center"
|
||||
class:my-4={settings.view == 'card'}
|
||||
>
|
||||
<span class="text-sm flex flex-row gap-2 items-center">
|
||||
Crossposts <hr class="w-full dark:border-zinc-800" />
|
||||
{post.crossposts.length}
|
||||
</span>
|
||||
|
||||
@@ -198,9 +198,7 @@
|
||||
<!-- <svelte:window on:keydown={handleKeydown} /> -->
|
||||
|
||||
<ul
|
||||
class="flex flex-col list-none {settings.view == 'card'
|
||||
? 'gap-3 md:gap-4'
|
||||
: 'divide-y'} divide-slate-200 dark:divide-zinc-800"
|
||||
class="flex flex-col list-none divide-y divide-slate-200 dark:divide-zinc-800"
|
||||
>
|
||||
{#if posts?.length == 0}
|
||||
<div class="h-full grid place-items-center">
|
||||
|
||||
Reference in new issue
Block a user