From e19c5adb42324987fca689bb4a2908f425767c37 Mon Sep 17 00:00:00 2001 From: eeseung Date: Fri, 3 Nov 2023 12:09:09 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20#32=20-=20Comment=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Comment/Comment.tsx | 89 ++++++++++++++++++++++++++++++ src/components/index.ts | 1 + 2 files changed, 90 insertions(+) create mode 100644 src/components/Comment/Comment.tsx diff --git a/src/components/Comment/Comment.tsx b/src/components/Comment/Comment.tsx new file mode 100644 index 00000000..e8df5865 --- /dev/null +++ b/src/components/Comment/Comment.tsx @@ -0,0 +1,89 @@ +import { PencilSquareIcon, TrashIcon } from '@heroicons/react/24/outline' +import Link from 'next/link' +import { Avatar } from '..' +import Button from '../common/Button/Button' + +export interface CommentProps { + commentId: string + user: { id: string; name: string; profile: string } + comment: string + date: Date + auth?: boolean + firstDepth?: boolean + replyCount?: number + onEdit?: (commentId: string) => void + onDelete?: (commentId: string) => void + onOpen?: (commentId: string) => void + onReply?: (commentId: string, userName: string) => void +} + +const Comment = ({ + commentId, + user, + comment, + date, + auth = false, + firstDepth = true, + replyCount = 0, + onEdit, + onDelete, + onOpen, + onReply, +}: CommentProps) => { + return ( +
+ +
+
+ + {user.name} + + {auth && onEdit && onDelete && ( +
+ + +
+ )} +
+

{comment}

+
+ {date.getFullYear().toString()}.{date.getMonth().toString()}. + {date.getDate().toString()} + {firstDepth && ( + <> + {' • '} + + {' • '} + + + )} +
+
+
+ ) +} + +export default Comment diff --git a/src/components/index.ts b/src/components/index.ts index 9209ce39..83af2a67 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -14,3 +14,4 @@ export { default as CategoryList } from './common/CategoryList/CategoryList' export { default as DropdownItem } from './common/Dropdown/DropdownItem' export { default as Dropdown } from './common/Dropdown/Dropdown' export { default as SpaceMemberList } from './common/SpaceMemberList/SpaceMemberList' +export { default as Comment } from './Comment/Comment'