-
Notifications
You must be signed in to change notification settings - Fork 4
Feat/comments pane #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Feat/comments pane #171
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4d70f3e
feat/comments-pane
grv-saini-20 85541e4
fix: overflow and drawer swipe
grv-saini-20 bdabfed
feat: Comment fragment
grv-saini-20 d588665
fix: comments added
grv-saini-20 76405e9
fix: comment fragment
grv-saini-20 e532187
feat: Comments reply
grv-saini-20 2336c57
fix: message input position
grv-saini-20 8766439
fix: post type shifted to types file
grv-saini-20 deb7a14
fix: one level deep only
grv-saini-20 5adce18
fix: drawer should only be render on mobile
grv-saini-20 8b910e2
fix: merge conflicts
grv-saini-20 68d7345
fix: comments on layout page
grv-saini-20 0db7b36
fix: format
grv-saini-20 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
platforms/metagram/src/lib/fragments/Comment/Comment.stories.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { ComponentProps } from 'svelte'; | ||
import { Comment } from '..'; | ||
import { comments } from '$lib/dummyData'; | ||
|
||
export default { | ||
title: 'UI/Comment', | ||
component: Comment, | ||
tags: ['autodocs'], | ||
render: (args: { Component: Comment; props: ComponentProps<typeof Comment> }) => ({ | ||
Component: Comment, | ||
props: args | ||
}) | ||
}; | ||
|
||
export const Main = { | ||
args: { | ||
comment: comments[0] | ||
} | ||
}; |
147 changes: 147 additions & 0 deletions
147
platforms/metagram/src/lib/fragments/Comment/Comment.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
<script lang="ts"> | ||
import { Like } from '$lib/icons'; | ||
import { Avatar } from '$lib/ui'; | ||
import { cn } from '$lib/utils'; | ||
import type { HTMLAttributes } from 'svelte/elements'; | ||
import type { CommentType } from '$lib/types'; | ||
interface ICommentProps extends HTMLAttributes<HTMLElement> { | ||
comment: CommentType; | ||
handleReply: () => void; | ||
} | ||
let visibleReplies = $state(2); | ||
const showMoreReplies = () => { | ||
visibleReplies = comment.replies.length; | ||
}; | ||
let { comment, handleReply, ...restProps }: ICommentProps = $props(); | ||
</script> | ||
|
||
<article {...restProps} class={cn([restProps.class].join(' '))}> | ||
<div class="align-start flex gap-2"> | ||
<Avatar src={comment.userImgSrc} size="sm" /> | ||
<div> | ||
<h3 class="font-semibold text-black">{comment.name}</h3> | ||
<p class="text-black-600 mt-0.5">{comment.comment}</p> | ||
</div> | ||
</div> | ||
<div class="ms-12 mt-2 flex items-center gap-2"> | ||
<button | ||
onclick={() => { | ||
if (!comment.isUpVoted) { | ||
comment.upVotes++; | ||
comment.isUpVoted = true; | ||
comment.isDownVoted = false; | ||
This conversation was marked as resolved.
Show resolved
Hide resolved
|
||
} | ||
}} | ||
> | ||
<Like | ||
size="18px" | ||
color={comment.isUpVoted | ||
? 'var(--color-brand-burnt-orange)' | ||
: 'var(--color-black-600)'} | ||
fill={comment.isUpVoted | ||
? 'var(--color-brand-burnt-orange)' | ||
: 'var(--color-black-600)'} | ||
/> | ||
</button> | ||
<p class="text-black-600 font-semibold">{comment.upVotes}</p> | ||
<button | ||
onclick={() => { | ||
if (!comment.isDownVoted) { | ||
comment.upVotes--; | ||
comment.isDownVoted = true; | ||
comment.isUpVoted = false; | ||
} | ||
}} | ||
> | ||
<Like | ||
size="18px" | ||
color={comment.isDownVoted | ||
? 'var(--color-brand-burnt-orange)' | ||
: 'var(--color-black-600)'} | ||
fill={comment.isDownVoted | ||
? 'var(--color-brand-burnt-orange)' | ||
: 'var(--color-black-600)'} | ||
class="rotate-180" | ||
/> | ||
</button> | ||
<span class="bg-black-600 inline-block h-1 w-1 rounded-full"></span> | ||
<button onclick={handleReply} class="text-black-600 font-semibold">Reply</button> | ||
<span class="bg-black-600 inline-block h-1 w-1 rounded-full"></span> | ||
<p class="text-black-600">{comment.time}</p> | ||
</div> | ||
{#if comment?.replies?.length} | ||
<ul class="ms-12 mt-4 space-y-2"> | ||
{#each comment.replies.slice(0, visibleReplies) as reply} | ||
<li> | ||
<div class="align-start flex gap-2"> | ||
<Avatar src={reply.userImgSrc} size="sm" /> | ||
<div> | ||
<h3 class="font-semibold text-black">{reply.name}</h3> | ||
<p class="text-black-600 mt-0.5">{reply.comment}</p> | ||
</div> | ||
</div> | ||
<div class="ms-12 mt-2 flex items-center gap-2"> | ||
<button | ||
onclick={() => { | ||
if (!reply.isUpVoted) { | ||
reply.upVotes++; | ||
reply.isUpVoted = true; | ||
reply.isDownVoted = false; | ||
} | ||
}} | ||
> | ||
<Like | ||
size="18px" | ||
color={reply.isUpVoted | ||
? 'var(--color-brand-burnt-orange)' | ||
: 'var(--color-black-600)'} | ||
fill={reply.isUpVoted | ||
? 'var(--color-brand-burnt-orange)' | ||
: 'var(--color-black-600)'} | ||
/> | ||
</button> | ||
<p class="text-black-600 font-semibold">{reply.upVotes}</p> | ||
<button | ||
onclick={() => { | ||
if (!reply.isDownVoted) { | ||
reply.upVotes--; | ||
reply.isDownVoted = true; | ||
reply.isUpVoted = false; | ||
} | ||
}} | ||
> | ||
<Like | ||
size="18px" | ||
color={reply.isDownVoted | ||
? 'var(--color-brand-burnt-orange)' | ||
: 'var(--color-black-600)'} | ||
fill={reply.isDownVoted | ||
? 'var(--color-brand-burnt-orange)' | ||
: 'var(--color-black-600)'} | ||
class="rotate-180" | ||
/> | ||
</button> | ||
<span class="bg-black-600 inline-block h-1 w-1 rounded-full"></span> | ||
<button onclick={handleReply} class="text-black-600 font-semibold" | ||
>Reply</button | ||
> | ||
<span class="bg-black-600 inline-block h-1 w-1 rounded-full"></span> | ||
<p class="text-black-600">{reply.time}</p> | ||
</div> | ||
</li> | ||
{/each} | ||
{#if comment.replies.length > visibleReplies} | ||
<button | ||
onclick={showMoreReplies} | ||
class="text-brand-burnt-orange mt-1 text-sm font-medium" | ||
> | ||
See {comment.replies.length - visibleReplies} more replies | ||
</button> | ||
{/if} | ||
</ul> | ||
{/if} | ||
</article> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.