Skip to content

✨ feat: 게시글 상세 댓글ui추가 #364

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jungmyunggi
Copy link
Collaborator

🔨 테스크

게시글 상세에 댓글 ui추가

image

  • detail 폴더 안에 전부 몰아넣어놨습니다.
  • 나중에 FSD로 변경할 때 이 컴포넌트만 따로 ui폴더로 넣으면 될거같아요

댓글 수정

{modifyId !== comment.id ? (
                    <p className="mt-1 text-gray-800">{comment.content}</p>
                  ) : (
                    <div className="">
                      <textarea className="w-[100%] mt-2 flex-1 bg-transparent p-2 rounded-md h-20 outline-none ring-2 ring-gray-300 border-transparent resize-none">
                        {comment.content}
                      </textarea>
                      <div className="flex justify-end gap-3 text-sm">
                        <button onClick={() => handleModify(null)} className="hover:bg-gray-200 py-2 px-4 rounded-lg">
                          취소
                        </button>
                        <button className="bg-primary hover:bg-primary/80 py-2 px-4 text-white  rounded-lg">
                          댓글 수정
                        </button>
                      </div>
                    </div>
                  )}
  • useState를 통해 수정하는 댓글을 저장하고 해당 댓글일 경우 textarea로 변경되게 했습니다.

댓글 삭제

function DeleteButton({ id, handleOpen }: { id: number; handleOpen: () => void }) {
  return (
    <div className="w-[100%] h-[100%] absolute top-0 left-0 z-[1000] bg-white/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0">
      <div className="flex flex-col fixed top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%] w-full max-w-xs md:max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg">
        <header className="flex flex-col space-y-2 text-center sm:text-left">
          <span className="text-lg font-semibold">댓글 삭제</span>
        </header>
        <section>
          <p className="text-sm text-muted-foreground text-center md:text-start">댓글을 정말로 삭제하시겠습니까?</p>
        </section>
        <footer className="flex flex-row justify-end space-x-2">
          <button onClick={handleOpen} className="py-2 px-4 rounded-sm hover:bg-gray-100">
            취소
          </button>
          <button className="bg-primary py-2 px-4 text-white rounded-sm hover:bg-primary/90">확인</button>
          {id}
        </footer>
      </div>
    </div>
  );
  • 기존의 shadcn의 모달은 화면 전체에 overlay를 걸어서 클릭시 모달 자체가 꺼지는 현상이 발생해서 따로 모달 컴포넌트를 만들었습니다.
  • 상세 모달 or 페이지에만 overlay가 나오도록 수정했고 overlay클릭시 모달이 꺼지는건 넣지 않았습니다.

📋 작업 내용

  • 댓글 UI구현
  • 댓글 수정/삭제 추가
  • 댓글 더보기 추가

📷 스크린 샷

image

@jungmyunggi jungmyunggi added the ✨ Feature 기능 구현 label Apr 2, 2025
@jungmyunggi jungmyunggi requested a review from junyeokk April 2, 2025 03:16
@jungmyunggi jungmyunggi self-assigned this Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature 기능 구현
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FE] 특정 블로그 글 클릭 시 상세 페이지/모달이 나오도록 수정
1 participant