From 4b28c273a7660077add2e81856cc9046709f3b74 Mon Sep 17 00:00:00 2001 From: typhoon0678 Date: Tue, 18 Feb 2025 16:37:00 +0900 Subject: [PATCH] =?UTF-8?q?style:=20=EB=8C=93=EA=B8=80=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/Header.tsx | 2 +- src/components/common/TextButton.tsx | 2 +- src/components/post/CommentCard.tsx | 82 ++++++++++++++++++++++++ src/components/post/CommentTextField.tsx | 37 +++++++++++ src/layout/LoadingLayout.tsx | 2 +- src/pages/post/PostPage.tsx | 36 +++++++++-- 6 files changed, 152 insertions(+), 9 deletions(-) create mode 100644 src/components/post/CommentCard.tsx create mode 100644 src/components/post/CommentTextField.tsx diff --git a/src/components/common/Header.tsx b/src/components/common/Header.tsx index fe8d40e..705e582 100644 --- a/src/components/common/Header.tsx +++ b/src/components/common/Header.tsx @@ -80,7 +80,7 @@ function Header() { ?
- user_image
void, addStyle?: string }) { return ( diff --git a/src/components/post/CommentCard.tsx b/src/components/post/CommentCard.tsx new file mode 100644 index 0000000..097c06f --- /dev/null +++ b/src/components/post/CommentCard.tsx @@ -0,0 +1,82 @@ +import {faker} from "@faker-js/faker/locale/ko"; +import {dateToKorean} from "../../common/util/date.tsx"; +import {MdOutlineAddComment, MdOutlineComment} from "react-icons/md"; +import {ChangeEvent, useState} from "react"; +import CommentTextField from "./CommentTextField.tsx"; + +function CommentCard({depth = 0}: { depth?: number }) { + + const [openComment, setOpenComment] = useState(depth !== 0); + const [commentInput, setCommentInput] = useState(""); + const [showTextField, setShowTextField] = useState(false); + + const handleCommentInput = (e: ChangeEvent) => { + setCommentInput(e.currentTarget.value); + } + const handleShowTextField = () => { + setShowTextField(prev => !prev); + } + const handleSubmit = (commentId: string | undefined) => { + confirm("댓글을 등록하시겠습니까?"); + alert("등록되었습니다."); + console.log(commentId); + } + + return ( +
+ {depth !== 0 &&
} +
+
+
+ user_image +

+ {faker.animal.cow()} +

+

+ {dateToKorean(faker.date.anytime())} +

+
+

+ {faker.lorem.paragraph()} +

+
+ {depth === 0 && + } +
+ +
+
+
+ {showTextField && + } +
+ {openComment && +
+ {Array.from({length: 2}).map(() => + (depth <= 2) + ? + : null)} +
+ } +
+
+ ); +} + +export default CommentCard; \ No newline at end of file diff --git a/src/components/post/CommentTextField.tsx b/src/components/post/CommentTextField.tsx new file mode 100644 index 0000000..39167d5 --- /dev/null +++ b/src/components/post/CommentTextField.tsx @@ -0,0 +1,37 @@ +import {ChangeEventHandler} from 'react'; +import {FillButton} from "../common/FillButton.tsx"; +import {TextButton} from "../common/TextButton.tsx"; + +interface CommentTextFieldProps { + value: string, + onChange: ChangeEventHandler, + commentId?: string, + handleSubmit: (commentId: string | undefined) => void, + handleShowTextField?: () => void, +} + +function CommentTextField(props: CommentTextFieldProps) { + + const {value, onChange, commentId, handleSubmit, handleShowTextField} = props; + + return ( +
+