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 ( +
+