|
29 | 29 | let commentValue: string = $state(''); |
30 | 30 | let commentInput: HTMLInputElement | undefined = $state(); |
31 | 31 |
|
| 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 | +
|
32 | 59 | const loadMore = () => { |
33 | 60 | if (loading || currentIndex >= dummyPosts.length) return; |
34 | 61 | loading = true; |
|
84 | 111 | {/if} |
85 | 112 |
|
86 | 113 | <Drawer bind:drawer> |
87 | | - <div> |
| 114 | + <ul class="pb-4"> |
88 | 115 | <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 |
90 | 119 | isLiked={false} |
91 | 120 | isDisliked={false} |
92 | 121 | 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} |
96 | 125 | handleReply={() => commentInput?.focus()} |
97 | 126 | 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} |
99 | 148 | <MessageInput |
100 | 149 | class="mt-4" |
101 | 150 | variant="comment" |
|
104 | 153 | handleSend={async () => alert('sdfs')} |
105 | 154 | bind:input={commentInput} |
106 | 155 | /> |
107 | | - </div> |
| 156 | + </ul> |
108 | 157 | </Drawer> |
0 commit comments