-
Notifications
You must be signed in to change notification settings - Fork 5
[UI] 상세페이지 댓글창 컴포넌트 구현 #93
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f0be1c0
#84 [DEL] 상태 속성 svg이미지 삭제
HiJuwon 7710025
#84 [FEAT] 댓글 관련 컴포넌트 모두 생성 및 초기 구조 정의
HiJuwon 1d35e00
#84 [FEAT] 댓글 입력창, 댓글 작성 버튼 구현
HiJuwon 34a979b
#84 [MOD] 댓글 영역 내 상하위 구조 개선
HiJuwon 8306cc7
#84 [FEAT] 댓글 입력하고 확인 버튼 누르면 댓글 목록에 댓글 아이템 생성되도록 구현
HiJuwon 724709f
#84 [FEAT] 댓글 목록 스타일링 완료, 댓글 컴포넌트 구현 완료
HiJuwon 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
src/components/DetailView/Comment/CommentCompletionButton.tsx
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,29 @@ | ||
| // CommentCompletionButton.tsx | ||
| // 상세페이지 댓글창) 댓글 입력 확인 버튼 컴포넌트 | ||
|
|
||
| interface CommentCompletionButtonProps { | ||
| isCommentFilled: boolean; // 댓글이 입력되었는지를 따지는 플래그 | ||
| onClick?: () => void; | ||
| } | ||
|
|
||
| const CommentCompletionButton = ({ isCommentFilled, onClick }: CommentCompletionButtonProps) => { | ||
| // 댓글이 입력되지 않으면: 버튼 비활성화 | ||
| const isDisabled = !isCommentFilled; | ||
|
|
||
| // 버튼 비활성화 상태일 때 or 활성화 상태일 때의 스타일링 구분 | ||
| const cursorClass = isDisabled ? '' : 'cursor-pointer'; | ||
| const bgColor = isDisabled ? 'bg-gray-200' : 'bg-primary-blue'; | ||
| const textColor = isDisabled ? 'text-gray-400' : 'text-gray-100'; | ||
|
|
||
| return ( | ||
| <button | ||
| disabled={isDisabled} | ||
| onClick={onClick} | ||
| className={`flex items-center justify-center px-[1.6rem] py-[0.8rem] font-small-b whitespace-nowrap rounded-md ${cursorClass} ${bgColor} ${textColor} transition-colors duration-300 ease-in-out`} | ||
| > | ||
| 확인 | ||
| </button> | ||
| ); | ||
| }; | ||
|
|
||
| export default CommentCompletionButton; |
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,45 @@ | ||
| // CommentInput.tsx | ||
| // 상세페이지 댓글창) 댓글 입력창 컴포넌트 | ||
|
|
||
| import { useState } from 'react'; | ||
| import CommentCompletionButton from './CommentCompletionButton'; | ||
|
|
||
| interface CommentIntputProps { | ||
| onAdd: (content: string) => void; | ||
| } | ||
|
|
||
| const CommentInput = ({ onAdd }: CommentIntputProps) => { | ||
| const [comment, setComment] = useState(''); | ||
|
|
||
| // 입력 시 | ||
| const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => { | ||
| setComment(e.target.value); | ||
| }; | ||
|
|
||
| const handleSubmit = () => { | ||
| if (comment.trim().length === 0) return; | ||
| onAdd(comment.trim()); | ||
| setComment(''); | ||
| }; | ||
|
|
||
| return ( | ||
| <div | ||
| className="flex flex-end items-end gap-[0.8rem] w-full h-[13rem] p-[2.4rem] bg-gray-100 rounded-lg" | ||
| style={{ | ||
| boxShadow: '0 10px 15px -3px rgba(0, 0, 0, 0.10), 0 4px 6px -2px rgba(0, 0, 0, 0.05)', | ||
| }} | ||
| > | ||
| {/* 댓글 입력창 영역 */} | ||
| <textarea | ||
| value={comment} | ||
| onChange={handleChange} | ||
| placeholder="댓글을 작성하세요." | ||
| className="w-full h-full font-body-r placeholder-gray-400 text-gray-600 focus:outline-none resize-none basic-scroll" | ||
| ></textarea> | ||
| {/* 댓글 작성 완료 버튼 */} | ||
| <CommentCompletionButton isCommentFilled={comment.trim().length > 0} onClick={handleSubmit} /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default CommentInput; |
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,34 @@ | ||
| // CommentItem.tsx | ||
| // 상세페이지 댓글창) 개별 댓글 컴포넌트 | ||
|
|
||
| import IcDummyProfile from '../../../assets/icons/gray-lg.svg'; | ||
|
|
||
| interface CommentItemProps { | ||
| author: string; // 댓글 작성자 | ||
| content: string; // 댓글 내용 | ||
| createAt: Date; // 댓글 작성 날짜 | ||
| } | ||
|
|
||
| const CommentItem = ({ author, content, createAt }: CommentItemProps) => { | ||
| return ( | ||
| <div className="flex items-start gap-[1.6rem] w-full"> | ||
| {/* 댓글 작성자 프로필: 현재는 더미이미지 삽입. 추후 데이터 받아와 연동 예정 */} | ||
| <img src={IcDummyProfile} alt="작성자 프로필" /> | ||
|
|
||
| <div className="flex flex-col gap-[0.8rem]"> | ||
| {/* 작성자 정보 */} | ||
| <div className="flex gap-[0.8rem]"> | ||
| {/* 작성자 이름 */} | ||
| <span className="font-body-b text-gray-600">{author}</span> | ||
| {/* 작성 시간 */} | ||
| <span className="font-small-r text-gray-500">{createAt.toLocaleString()}</span> | ||
| </div> | ||
|
|
||
| {/* 댓글 내용 */} | ||
| <div className="font-body-r text-gray-600">{content}</div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default CommentItem; |
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,57 @@ | ||
| // CommentSection.tsx | ||
| // 상세페이지 댓글창) 댓글 전체 영역 컴포넌트 | ||
|
|
||
| import { useState } from 'react'; | ||
| import CommentInput from './CommentInput'; | ||
| import CommentItem from './CommentItem'; | ||
|
|
||
| interface Comment { | ||
| author: string; // 댓글 작성자 | ||
| content: string; // 댓글 내용 | ||
| createAt: Date; // 댓글 작성 날짜 | ||
| } | ||
|
|
||
| const CommentSection = () => { | ||
| const [comments, setComments] = useState<Comment[]>([]); // comments라는 상태를 배열로 관리 | ||
|
|
||
| const handleAddComment = (content: string) => { | ||
| const newComment: Comment = { | ||
| author: '전채운', // 추후 로그인 유저로 대체 | ||
| content, | ||
| createAt: new Date(), | ||
| }; | ||
| setComments((prev) => [...prev, newComment]); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="flex flex-col gap-[3.2rem] w-full h-[41rem]"> | ||
| {/* 댓글 목록 헤더 */} | ||
| <div className="flex gap-[0.8rem]"> | ||
| <div className="font-title-sub-r text-gray-600">댓글</div> | ||
| {/* 댓글 개수를 숫자로 렌더링 */} | ||
| <div className="font-title-sub-r text-gray-500">{comments.length}</div> | ||
| </div> | ||
|
|
||
| <div className="flex flex-col gap-[1.6rem] w-full h-[35rem]"> | ||
| {/* 댓글 목록 */} | ||
| <div className="flex flex-col gap-[2.4rem] w-full h-full overflow-y-auto basic-scroll"> | ||
| {comments.length === 0 ? ( | ||
| <div className="flex items-center justify-center w-full h-full"> | ||
| {/* 댓글 개수가 0개일 때: 댓글 목록의 초기 문구를 띄우도록 */} | ||
| <div className="font-body-r text-gray-600">댓글을 작성하세요.</div> | ||
| </div> | ||
| ) : ( | ||
| comments.map(({ author, content, createAt }) => ( | ||
| <CommentItem author={author} content={content} createAt={createAt} /> | ||
| )) | ||
| )} | ||
| </div> | ||
|
|
||
| {/* 댓글 입력창 */} | ||
| <CommentInput onAdd={handleAddComment} /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default CommentSection; |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
댓글 최대 글자수는 없는지 궁금합니다!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
화면설계서 상에는 댓글 최대 글자 제한은 없었는데, 한번 여쭤보겠습니다~~!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
댓글 최대 글자수는 없는 것으로 정해졌습니다