Skip to content

Commit deb7a14

Browse files
committed
fix: one level deep only
1 parent 8766439 commit deb7a14

File tree

2 files changed

+59
-6
lines changed

2 files changed

+59
-6
lines changed

platforms/metagram/src/lib/fragments/Comment/Comment.svelte

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
import { Avatar } from '$lib/ui';
44
import { cn } from '$lib/utils';
55
import type { HTMLAttributes } from 'svelte/elements';
6-
import CommentComponent from './Comment.svelte';
76
import type { CommentType } from '$lib/types';
87
98
interface ICommentProps extends HTMLAttributes<HTMLElement> {
109
comment: CommentType;
11-
handleReply: (id: string) => void;
10+
handleReply: () => void;
1211
}
1312
1413
let visibleReplies = $state(2);
@@ -70,7 +69,7 @@
7069
/>
7170
</button>
7271
<span class="bg-black-600 inline-block h-1 w-1 rounded-full"></span>
73-
<button onclick={() => handleReply(comment.commentId)} class="text-black-600 font-semibold"
72+
<button onclick={handleReply} class="text-black-600 font-semibold"
7473
>Reply</button
7574
>
7675
<span class="bg-black-600 inline-block h-1 w-1 rounded-full"></span>
@@ -80,7 +79,61 @@
8079
<ul class="ms-12 mt-4 space-y-2">
8180
{#each comment.replies.slice(0, visibleReplies) as reply}
8281
<li>
83-
<CommentComponent comment={reply} {handleReply} />
82+
<div class="align-start flex gap-2">
83+
<Avatar src={reply.userImgSrc} size="sm" />
84+
<div>
85+
<h3 class="font-semibold text-black">{reply.name}</h3>
86+
<p class="text-black-600 mt-0.5">{reply.comment}</p>
87+
</div>
88+
</div>
89+
<div class="ms-12 mt-2 flex items-center gap-2">
90+
<button
91+
onclick={() => {
92+
if (!reply.isUpVoted) {
93+
reply.upVotes++;
94+
reply.isUpVoted = true;
95+
reply.isDownVoted = false;
96+
}
97+
}}
98+
>
99+
<Like
100+
size="18px"
101+
color={reply.isUpVoted
102+
? 'var(--color-brand-burnt-orange)'
103+
: 'var(--color-black-600)'}
104+
fill={reply.isUpVoted
105+
? 'var(--color-brand-burnt-orange)'
106+
: 'var(--color-black-600)'}
107+
/>
108+
</button>
109+
<p class="text-black-600 font-semibold">{reply.upVotes}</p>
110+
<button
111+
onclick={() => {
112+
if (!reply.isDownVoted) {
113+
reply.upVotes--;
114+
reply.isDownVoted = true;
115+
reply.isUpVoted = false;
116+
}
117+
}}
118+
>
119+
<Like
120+
size="18px"
121+
color={reply.isDownVoted
122+
? 'var(--color-brand-burnt-orange)'
123+
: 'var(--color-black-600)'}
124+
fill={reply.isDownVoted
125+
? 'var(--color-brand-burnt-orange)'
126+
: 'var(--color-black-600)'}
127+
class="rotate-180"
128+
/>
129+
</button>
130+
<span class="bg-black-600 inline-block h-1 w-1 rounded-full"></span>
131+
<button onclick={handleReply} class="text-black-600 font-semibold"
132+
>Reply</button
133+
>
134+
<span class="bg-black-600 inline-block h-1 w-1 rounded-full"></span>
135+
<p class="text-black-600">{reply.time}</p>
136+
</div>
84137
</li>
85138
{/each}
86139
{#if comment.replies.length > visibleReplies}

platforms/metagram/src/routes/(protected)/home/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@
115115
<li class="mb-4">
116116
<Comment
117117
{comment}
118-
handleReply={(id) => {
119-
activeReplyToId = id;
118+
handleReply={() => {
119+
activeReplyToId = comment.commentId;
120120
commentInput?.focus();
121121
}}
122122
/>

0 commit comments

Comments
 (0)