feat: Make comments fully collapse
This commit is contained in:
1 parent
801278a1e1
commit
895a571e4f
3 files changed
+18
-4
No files matched your search
@@ -92,6 +92,13 @@
|
|||||||
<span class="opacity-50">{postData.creator.name}</span>
|
<span class="opacity-50">{postData.creator.name}</span>
|
||||||
</span>
|
</span>
|
||||||
<h1 class="font-bold text-lg">{post.name}</h1>
|
<h1 class="font-bold text-lg">{post.name}</h1>
|
||||||
|
<a
|
||||||
|
href={post.url}
|
||||||
|
class="text-sky-400 max-w-[48ch] overflow-hidden
|
||||||
|
whitespace-nowrap text-ellipsis text-xs hover:underline"
|
||||||
|
>
|
||||||
|
{post.url}
|
||||||
|
</a>
|
||||||
{#if post.thumbnail_url}
|
{#if post.thumbnail_url}
|
||||||
<img
|
<img
|
||||||
src={post.thumbnail_url}
|
src={post.thumbnail_url}
|
||||||
|
|||||||
@@ -1,17 +1,22 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ArrowDown, ArrowUp, Icon } from 'svelte-hero-icons'
|
import { ArrowDown, ArrowUp, Icon, Minus, Plus } from 'svelte-hero-icons'
|
||||||
import Avatar from './Avatar.svelte'
|
import Avatar from './Avatar.svelte'
|
||||||
import type { CommentNodeI } from './comments.js'
|
import type { CommentNodeI } from './comments.js'
|
||||||
import SvelteMarkdown from 'svelte-markdown'
|
import SvelteMarkdown from 'svelte-markdown'
|
||||||
import RelativeDate from '$lib/components/RelativeDate.svelte'
|
import RelativeDate from '$lib/components/RelativeDate.svelte'
|
||||||
|
import Button from '$lib/components/Button.svelte'
|
||||||
|
import { Color } from '$lib/ui/colors.js'
|
||||||
|
|
||||||
export let node: CommentNodeI
|
export let node: CommentNodeI
|
||||||
export let open = true
|
export let open = true
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<li class="py-3">
|
<li class="py-3">
|
||||||
<details {open} class="flex flex-col gap-1">
|
<details bind:open class="flex flex-col gap-1">
|
||||||
<summary class="flex flex-row cursor-pointer arrow gap-2 items-center">
|
<summary class="flex flex-row cursor-pointer arrow gap-2 items-center">
|
||||||
|
<!-- <button class="-z-10">
|
||||||
|
<Icon src={open ? Minus : Plus} width={12} mini />
|
||||||
|
</button> -->
|
||||||
<Avatar
|
<Avatar
|
||||||
url={node.comment_view.creator.avatar ??
|
url={node.comment_view.creator.avatar ??
|
||||||
`https://api.dicebear.com/6.x/initials/svg?seed=${node.comment_view.creator.name}`}
|
`https://api.dicebear.com/6.x/initials/svg?seed=${node.comment_view.creator.name}`}
|
||||||
@@ -47,5 +52,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<slot />
|
||||||
</details>
|
</details>
|
||||||
</li>
|
</li>
|
||||||
@@ -11,12 +11,13 @@
|
|||||||
<ul
|
<ul
|
||||||
class={isParent
|
class={isParent
|
||||||
? ''
|
? ''
|
||||||
: 'ml-2 mx-2.5 px-2.5 border-l-2 border-black/10 dark:border-white/10'}
|
: 'ml-2 mt-2 mx-2.5 px-2.5 border-l-2 border-black/10 dark:border-white/10'}
|
||||||
>
|
>
|
||||||
{#each nodes.slice(0, maxComments) as node}
|
{#each nodes.slice(0, maxComments) as node}
|
||||||
<Comment {node} open={true} />
|
<Comment {node} open={true}>
|
||||||
{#if node.children?.length > 0}
|
{#if node.children?.length > 0}
|
||||||
<svelte:self nodes={node.children} isParent={false} />
|
<svelte:self nodes={node.children} isParent={false} />
|
||||||
{/if}
|
{/if}
|
||||||
|
</Comment>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
Reference in new issue
Block a user