feat: Add comment trees
This commit is contained in:
1 parent
83608fdaa6
commit
09d86dd721
13 files changed
+325
-91
No files matched your search
@@ -0,0 +1,47 @@
|
||||
<script lang="ts">
|
||||
import { ArrowDown, ArrowUp, Icon } from 'svelte-hero-icons'
|
||||
import Avatar from './Avatar.svelte'
|
||||
import type { CommentNodeI } from './comments.js'
|
||||
import SvelteMarkdown from 'svelte-markdown'
|
||||
import RelativeDate from '$lib/components/RelativeDate.svelte'
|
||||
|
||||
export let node: CommentNodeI
|
||||
</script>
|
||||
|
||||
<li class="py-2">
|
||||
<details open class="flex flex-col gap-1">
|
||||
<summary class="flex flex-row cursor-pointer arrow gap-2 items-center">
|
||||
<Avatar
|
||||
url={node.comment_view.creator.avatar ??
|
||||
`https://api.dicebear.com/6.x/initials/svg?seed=${node.comment_view.creator.name}`}
|
||||
width={24}
|
||||
/>
|
||||
<span class="text-sm">{node.comment_view.creator.name}</span>
|
||||
<span class="text-sm opacity-60">
|
||||
{node.comment_view.counts.score} point{node.comment_view.counts.score ==
|
||||
1
|
||||
? ''
|
||||
: 's'}
|
||||
</span>
|
||||
<span class="text-sm opacity-60">
|
||||
<RelativeDate date={new Date(node.comment_view.comment.published)} />
|
||||
</span>
|
||||
</summary>
|
||||
<div class="mt-1">
|
||||
<div class="flex flex-col gap-1">
|
||||
<SvelteMarkdown source={node.comment_view.comment.content} />
|
||||
<div class="flex flex-row gap-2">
|
||||
<button>
|
||||
<Icon src={ArrowUp} width={16} mini />
|
||||
</button>
|
||||
<span class="text-sm font-medium">
|
||||
{node.comment_view.counts.score}
|
||||
</span>
|
||||
<button>
|
||||
<Icon src={ArrowDown} width={16} mini />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</li>
|
||||
Reference in new issue
Block a user