Skip to content

Commit

Permalink
design: 게시글 상세 페이지 디자인 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ojm51 committed Aug 18, 2024
1 parent 1d8d058 commit 5286e59
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 30 deletions.
12 changes: 7 additions & 5 deletions components/AddComment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ function AddComment({ id, setCommentList }: AddCommentProps) {
/>
);
})}
<AddButton
buttonText="등록"
isFormComplete={isFormComplete}
onClick={postComment}
/>
<div className="text-right">
<AddButton
buttonText="등록"
isFormComplete={isFormComplete}
onClick={postComment}
/>
</div>
</div>
);
}
Expand Down
5 changes: 3 additions & 2 deletions components/AllArticleList/AllArticle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ import Image from "next/image";
import profileImage from "@/assets/images/img_profile.png";
import likeIconFull from "@/assets/images/ic_heart_full.png";
import likeIconEmpty from "@/assets/images/ic_heart_empty.png";
import defaultProductImage from "@/assets/images/img_product_empty.png";

interface AllArticleProps {
article: Article;
}

function AllArticle({ article }: AllArticleProps) {
const { id, title, image, writer, likeCount, createdAt } = article;

const [isLikeClicked, setIsLikeClicked] = useState<boolean>(false);
const productImage = image || defaultProductImage;

const handleLikeButtonClick = () => {
setIsLikeClicked((prevIsLikeClicked) => !prevIsLikeClicked);
Expand All @@ -28,7 +29,7 @@ function AllArticle({ article }: AllArticleProps) {
<h4 className={styles.title}>{title}</h4>
<Image
className={styles.productImage}
src={image}
src={productImage}
alt="상품 이미지"
width={72}
height={72}
Expand Down
26 changes: 20 additions & 6 deletions components/CommentList/Comment.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { IComment } from "@/types/comment";
import getTimeElapsed from "@/lib/getTimeElapsed";

import Image from "next/image";
import defaultProfileImage from "@/assets/images/img_profile.png";
import kebabMenuIcon from "@/assets/images/ic_kebab.png";

interface CommentProps {
comment: IComment;
Expand All @@ -14,19 +16,31 @@ function Comment({ comment }: CommentProps) {
const timeElapsed = getTimeElapsed(new Date(updatedAt));

return (
<div className="comment-wrapper">
<div className="comment-content">{content}</div>
<div className="writer-wrapper">
<div className="mb-6 border-b border-gray-200 bg-[#fcfcfc] pb-3">
<div className="mb-6 flex items-center justify-between">
<div>{content}</div>
<button>
<Image
src={kebabMenuIcon}
alt="케밥 메뉴 아아콘"
width={24}
height={24}
/>
</button>
</div>
<div className="flex items-center justify-start gap-2">
<Image
className="writer image"
src={profileImage}
alt={`${writer.nickname}`}
width={40}
height={40}
/>
<div className="comment-info">
<div className="nickname">{writer.nickname}</div>
<div className="time-elapsed">{timeElapsed}</div>
<div className="flex flex-col items-start justify-start">
<div className="text-xs font-normal text-gray-600">
{writer.nickname}
</div>
<div className="text-xs font-normal text-gray-400">{timeElapsed}</div>
</div>
</div>
</div>
Expand Down
36 changes: 21 additions & 15 deletions components/DetailArticle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ function DetailArticle({ article }: DetailArticleProps) {
<section>
<div className="mb-6 border-b">
<div className="mb-4 flex items-center justify-between">
<h3>{title}</h3>
<Image
src={kebabMenuIcon}
alt="케밥 메뉴 아아콘"
width={24}
height={24}
/>
<h3 className="text-xl font-bold text-gray-800">{title}</h3>
<button>
<Image
src={kebabMenuIcon}
alt="케밥 메뉴 아아콘"
width={24}
height={24}
/>
</button>
</div>
<div className="mb-4 flex items-center justify-start">
<div className="mr-8 flex items-center justify-start gap-4 border-r">
Expand All @@ -41,24 +43,28 @@ function DetailArticle({ article }: DetailArticleProps) {
height={40}
/>
<div className="mr-8 flex items-center justify-between gap-2">
<h5>{writer.nickname || "Anonymous"}</h5>
<h5>{formatDate(createdAt)}</h5>
<h5 className="text-sm font-medium text-gray-600">
{writer.nickname || "Anonymous"}
</h5>
<h5 className="text-sm font-normal text-gray-400">
{formatDate(createdAt)}
</h5>
</div>
</div>
<div className="flex items-center justify-between gap-1 rounded-full border border-gray-200 px-3 py-1">
<button onClick={handleLikeButtonClick}>
<button onClick={handleLikeButtonClick}>
<div className="flex items-center justify-center gap-1 rounded-full border border-gray-200 px-3 py-1">
<Image
src={isLikeClicked ? likeIconFull : likeIconEmpty}
alt="좋아요 아이콘"
width={32}
height={32}
/>
</button>
<h5>{likeCount}</h5>
</div>
<h5 className="text-gray-500">{likeCount}</h5>
</div>
</button>
</div>
</div>
<h4>{content}</h4>
<h4 className="text-lg font-normal text-gray-800">{content}</h4>
</section>
);
}
Expand Down
8 changes: 6 additions & 2 deletions pages/board/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ function DetailBoard({

return (
<div>
<DetailArticle article={article} />
<AddComment id={id} setCommentList={setCommentList} />
<div className="mb-8">
<DetailArticle article={article} />
</div>
<div className="mb-10">
<AddComment id={id} setCommentList={setCommentList} />
</div>
<CommentList commentList={commentList} />
<ReturnButton href="/boards" text="목록으로 돌아가기" />
</div>
Expand Down

0 comments on commit 5286e59

Please sign in to comment.