Skip to content

Commit d588665

Browse files
committed
fix: comments added
1 parent bdabfed commit d588665

File tree

1 file changed

+56
-7
lines changed

1 file changed

+56
-7
lines changed

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

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,33 @@
2929
let commentValue: string = $state('');
3030
let commentInput: HTMLInputElement | undefined = $state();
3131
32+
const comments = Array.from({length: 50}, (_, i) => ({
33+
userImgSrc: "https://picsum.photos/800",
34+
name: "user" + (i + 1),
35+
commentId: i + 1,
36+
comment: "this is the dummy comment which is commented by user" + (i + 1),
37+
replies: [
38+
{
39+
userImgSrc: "https://picsum.photos/800",
40+
name: "user" + (i + 1) + "x",
41+
commentId: (i + 1) + "x",
42+
comment: "this is the dummy reply which is replied by another" + i + "x",
43+
},
44+
{
45+
userImgSrc: "https://picsum.photos/800",
46+
name: "user" + (i + 1) + "y",
47+
commentId: i + 1 + "y",
48+
comment: "this is the dummy reply which is replied by another" + i + "y",
49+
}
50+
,{
51+
userImgSrc: "https://picsum.photos/800",
52+
name: "user" + (i + 1) + "z",
53+
commentId: i + 1 + "z",
54+
comment: "this is the dummy reply which is replied by another" + i + "z",
55+
}
56+
]
57+
}))
58+
3259
const loadMore = () => {
3360
if (loading || currentIndex >= dummyPosts.length) return;
3461
loading = true;
@@ -84,18 +111,40 @@
84111
{/if}
85112

86113
<Drawer bind:drawer>
87-
<div>
114+
<ul class="pb-4">
88115
<h3 class="text-black-600 mb-6 text-center">32 Comments</h3>
89-
<Comment
116+
{#each comments as comment}
117+
<li class="mb-4">
118+
<Comment
90119
isLiked={false}
91120
isDisliked={false}
92121
likeCount={0}
93-
name="Luka Garcia"
94-
comment="i was thinking of making it to the conference so we could take some more fire pictures like last time"
95-
imgSrc="https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250"
122+
name={comment.name}
123+
comment={comment.comment}
124+
imgSrc={comment.userImgSrc}
96125
handleReply={() => commentInput?.focus()}
97126
time={'2 minutes ago'}
98-
/>
127+
/>
128+
{#if comment.replies}
129+
<ul class="ms-12 mt-4">
130+
{#each comment.replies as reply}
131+
<li class="mb-4">
132+
<Comment
133+
isLiked={false}
134+
isDisliked={false}
135+
likeCount={0}
136+
name={reply.name}
137+
comment={reply.comment}
138+
imgSrc={reply.userImgSrc}
139+
handleReply={() => commentInput?.focus()}
140+
time={'2 minutes ago'}
141+
/>
142+
</li>
143+
{/each}
144+
</ul>
145+
{/if}
146+
</li>
147+
{/each}
99148
<MessageInput
100149
class="mt-4"
101150
variant="comment"
@@ -104,5 +153,5 @@
104153
handleSend={async () => alert('sdfs')}
105154
bind:input={commentInput}
106155
/>
107-
</div>
156+
</ul>
108157
</Drawer>

0 commit comments

Comments
 (0)