From 815a6d2385c91cdf2376b89669f834d211b037a8 Mon Sep 17 00:00:00 2001 From: Xylight Date: Fri, 6 Sep 2024 15:17:35 -0700 Subject: [PATCH] feat: add cancel button to commentform --- .../components/lemmy/comment/Comment.svelte | 5 ++- .../lemmy/comment/CommentForm.svelte | 38 +++++++++++-------- .../lemmy/post/media/PostImage.svelte | 2 +- .../components/markdown/MarkdownEditor.svelte | 4 +- .../post/[instance]/[id=integer]/+page.svelte | 2 + 5 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/lib/components/lemmy/comment/Comment.svelte b/src/lib/components/lemmy/comment/Comment.svelte index 5291649f..a2d7bfa8 100644 --- a/src/lib/components/lemmy/comment/Comment.svelte +++ b/src/lib/components/lemmy/comment/Comment.svelte @@ -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 }} > -

{$t('comment.reply')}

+
+ {$t('comment.reply')} +
(replying = false)} /> {/if} diff --git a/src/lib/components/lemmy/comment/CommentForm.svelte b/src/lib/components/lemmy/comment/CommentForm.svelte index 688f8746..208a7c6a 100644 --- a/src/lib/components/lemmy/comment/CommentForm.svelte +++ b/src/lib/components/lemmy/comment/CommentForm.svelte @@ -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} > +
{#if actions} -
- -
+ + {/if} {/if} diff --git a/src/lib/components/lemmy/post/media/PostImage.svelte b/src/lib/components/lemmy/post/media/PostImage.svelte index baadac66..3582e5d5 100644 --- a/src/lib/components/lemmy/post/media/PostImage.svelte +++ b/src/lib/components/lemmy/post/media/PostImage.svelte @@ -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" > diff --git a/src/lib/components/markdown/MarkdownEditor.svelte b/src/lib/components/markdown/MarkdownEditor.svelte index 85955493..fb239b29 100644 --- a/src/lib/components/markdown/MarkdownEditor.svelte +++ b/src/lib/components/markdown/MarkdownEditor.svelte @@ -256,7 +256,9 @@ overflow-hidden transition-colors {$$props.class}" {/if} {#if previewButton} -
+
{#if previewButton} {#if post.post_view.post.body}
@@ -356,6 +357,7 @@ preview={commenting} placeholder={commenting ? undefined : $t('routes.post.addComment')} rows={commenting ? 7 : 1} + on:cancel={() => (commenting = false)} /> {/if} {/if}