feat: add cancel button to commentform

This commit is contained in:
Xylight committed 2024-09-06 15:17:38 -07:00
1 parent 34300a5bdf
commit 815a6d2385
5 files changed
+33 -18

No files matched your search

@@ -218,7 +218,9 @@
class="max-w-full my-2 border-l border-slate-200 dark:border-zinc-800 pl-4"
transition:slide={{ axis: 'y', duration: 400, easing: expoOut }}
>
<h1 class="font-bold text-sm mb-2">{$t('comment.reply')}</h1>
<div class="font-medium text-sm mb-2">
{$t('comment.reply')}
</div>
<CommentForm
{postId}
parentId={node.comment_view.comment.id}
@@ -234,6 +236,7 @@
]
replying = false
}}
on:cancel={() => (replying = false)}
/>
</div>
{/if}
@@ -9,6 +9,7 @@
import { placeholders } from '$lib/util.js'
import { Button } from 'mono-svelte'
import { t } from '$lib/translations'
import { errorMessage } from '$lib/lemmy/error'
export let postId: number
export let parentId: number | undefined = undefined
@@ -20,6 +21,7 @@
const dispatch = createEventDispatcher<{
comment: CommentResponse
confirm: string
cancel: boolean
}>()
export let value = ''
@@ -48,7 +50,7 @@
} catch (err) {
console.error(err)
toast({
content: err as any,
content: errorMessage(err as any),
type: 'error',
})
}
@@ -73,7 +75,7 @@
? $t('comment.locked')
: banned
? $t('comment.banned')
: placeholder ?? placeholders.get('comment')}
: (placeholder ?? placeholders.get('comment'))}
bind:value
disabled={locked || loading || banned}
on:confirm={() => {
@@ -85,20 +87,26 @@
on:focus
previewButton={previewAction}
>
<div class="flex-1" />
{#if actions}
<div class="ml-auto">
<Button
large
on:click={submit}
color="primary"
size="lg"
class="sm:ml-auto w-28"
{loading}
disabled={locked || loading || banned}
>
{$t('form.submit')}
</Button>
</div>
<Button
on:click={() => dispatch('cancel', true)}
color="tertiary"
size="lg"
class=" w-28"
>
{$t('common.cancel')}
</Button>
<Button
on:click={submit}
color="primary"
size="lg"
class=" w-28"
{loading}
disabled={locked || loading || banned}
>
{$t('form.submit')}
</Button>
{/if}
</MarkdownEditor>
{/if}
@@ -23,7 +23,7 @@
class="container mx-auto z-10 rounded-xl max-h-[60vh] relative overflow-hidden bg-slate-100 dark:bg-zinc-900"
data-sveltekit-preload-data="off"
aria-label={post.name}
on:click={() => showImage(bestImageURL(post, false, 2048))}
on:click={() => showImage(bestImageURL(post, false, -1))}
role="button"
tabindex="0"
>
@@ -256,7 +256,9 @@ overflow-hidden transition-colors {$$props.class}"
{/if}
{#if previewButton}
<div class="p-2 flex items-center w-full bg-white dark:bg-zinc-950">
<div
class="p-2 flex flex-row items-center w-full bg-white dark:bg-zinc-950 gap-1"
>
{#if previewButton}
<MultiSelect
bind:selected={previewing}