diff --git a/src/App.tsx b/src/App.tsx old mode 100644 new mode 100755 index a660f2d..c99dbb9 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,10 @@ import { useEffect, useState } from "react"; import "./index.css"; import BookList from "./BookList/BookList"; + +import Comment from './component/Comment'; // Adjust the import path if necessary + + function App() { const [books, setBooks] = useState([]); @@ -57,6 +61,13 @@ function App() { + ); } diff --git a/src/component/Comment.css b/src/component/Comment.css new file mode 100755 index 0000000..e94367f --- /dev/null +++ b/src/component/Comment.css @@ -0,0 +1,66 @@ +.comment { + border: 1px solid #e1e1e1; + border-radius: 8px; + padding: 16px; + margin: 16px 0; + background-color: #fff; + } + + .comment-header { + display: flex; + align-items: center; + justify-content: space-between; + } + + .comment-rating { + display: flex; + } + + .star { + color: #ccc; + font-size: 24px; + } + + .star.filled { + color: #ffc107; + } + + .comment-author { + display: flex; + align-items: center; + } + + .author-image { + width: 40px; + height: 40px; + border-radius: 50%; + margin-right: 8px; + } + + .author-name { + font-weight: bold; + } + + .comment-body { + margin: 16px 0; + } + + .comment-text { + font-size: 16px; + color: #333; + } + + .comment-footer { + display: flex; + justify-content: space-between; + } + + .comment-actions { + display: flex; + gap: 16px; + } + + .likes, .replies { + font-size: 14px; + color: #888; + } \ No newline at end of file diff --git a/src/component/Comment.tsx b/src/component/Comment.tsx new file mode 100755 index 0000000..8c5756d --- /dev/null +++ b/src/component/Comment.tsx @@ -0,0 +1,40 @@ +import React from 'react'; +import './Comment.css'; + +interface CommentProps { + rating: number; // raing(Rate) -> 도서 평점에만 사용됨. 삭제? + author: string; // user_id(User) + text: string; // comment(Comment) + likes: number; // like + replies: number; // 대댓글은 erd에 없음. +} + +const Comment: React.FC = ({ rating, author, text, likes, replies }) => { + const stars = Array(5).fill(0).map((_, i) => i < rating ? '★' : '☆'); + + return ( +
+
+
+ {stars.map((star, index) => ( + {star} + ))} +
+
+ {author} +
+
+
+

{text}

+
+
+
+ 👍 {likes} + 💬 {replies} +
+
+
+ ); +}; + +export default Comment; \ No newline at end of file