feat: add comment reply preview

This commit is contained in:
James Xylight committed 2025-06-18 10:52:41 -07:00
1 parent f622d143ea
commit 71411dadf1
2 files changed
+29 -6

No files matched your search

@@ -8,12 +8,13 @@
import { t } from '$lib/i18n/translations' import { t } from '$lib/i18n/translations'
import { getClient } from '$lib/lemmy.svelte.js' import { getClient } from '$lib/lemmy.svelte.js'
import { errorMessage } from '$lib/lemmy/error' import { errorMessage } from '$lib/lemmy/error'
import { Button, Modal, toast } from 'mono-svelte' import { Button, Material, Modal, toast } from 'mono-svelte'
import { Bookmark, Icon, Microphone, Pencil, Trash } from 'svelte-hero-icons' import { Bookmark, Icon, Microphone, Pencil, Trash } from 'svelte-hero-icons'
import type { ClassValue } from 'svelte/elements' import type { ClassValue } from 'svelte/elements'
import ShieldIcon from '../moderation/ShieldIcon.svelte' import ShieldIcon from '../moderation/ShieldIcon.svelte'
import CommentForm from './CommentForm.svelte' import CommentForm from './CommentForm.svelte'
import type { CommentNodeI } from './comments.svelte' import type { CommentNodeI } from './comments.svelte'
import CommentItem from './CommentItem.svelte'
interface Props { interface Props {
node: CommentNodeI node: CommentNodeI
@@ -95,8 +96,27 @@
} }
> >
{#snippet customTitle()} {#snippet customTitle()}
<span>{replying ? $t('comment.reply') : $t('form.edit')}</span> <div>{replying ? $t('comment.reply') : $t('form.edit')}</div>
{/snippet} {/snippet}
{#if replying}
<Material
rounding="2xl"
color="uniform"
class="max-h-48 overflow-hidden relative"
>
<UserLink user={node.comment_view.creator} />
<CommentItem
meta={false}
comment={node.comment_view}
class="pt-0 text-slate-700 dark:text-zinc-300"
actions={false}
/>
<div
class="bg-gradient-to-b -mx-4 from-white/0 to-white dark:from-zinc-900/0 dark:to-zinc-900 absolute bottom-0 w-full h-24"
></div>
</Material>
{/if}
<form <form
onsubmit={e => { onsubmit={e => {
e.preventDefault() e.preventDefault()
@@ -210,11 +230,11 @@
</span> </span>
</button> </button>
{/if} {/if}
<div class={['expand', open && 'open', contentClass]}> <div class={['expand max-w-full', open && 'open', contentClass]}>
<div id="comment-content w-full"> <div id="comment-content">
<div <div
class="flex flex-col whitespace-pre-wrap class="flex flex-col whitespace-pre-wrap
max-w-full gap-1 mt-1 relative" max-w-full gap-1 mt-1 relative w-full"
> >
<Markdown <Markdown
source={node.comment_view.comment.content} source={node.comment_view.comment.content}
@@ -241,7 +261,7 @@
.expand { .expand {
display: grid; display: grid;
grid-template-rows: 0fr; grid-template-rows: 0fr;
grid-template-columns: 1fr; grid-template-columns: 100%;
overflow: hidden; overflow: hidden;
transition: grid-template-rows 0.5s cubic-bezier(0.19, 1, 0.22, 1); transition: grid-template-rows 0.5s cubic-bezier(0.19, 1, 0.22, 1);
} }
@@ -14,6 +14,7 @@
meta?: boolean meta?: boolean
class?: string class?: string
commentClass?: ClassValue commentClass?: ClassValue
actions?: boolean
} }
let { let {
@@ -22,6 +23,7 @@
meta = true, meta = true,
class: clazz = '', class: clazz = '',
commentClass = '', commentClass = '',
actions = true,
...rest ...rest
}: Props = $props() }: Props = $props()
</script> </script>
@@ -71,6 +73,7 @@
node={{ children: [], comment_view: comment, depth: 1, expanded: true }} node={{ children: [], comment_view: comment, depth: 1, expanded: true }}
replying={false} replying={false}
{meta} {meta}
{actions}
{...rest} {...rest}
class={commentClass} class={commentClass}
/> />