From 5a248f442e3a2b4659fd826406e0eee08e789f84 Mon Sep 17 00:00:00 2001 From: monoid Date: Tue, 1 Apr 2025 00:43:33 +0900 Subject: [PATCH] CommentPagination --- src/App.tsx | 3 +- src/Comment.tsx | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index 33c0198..28c2406 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,5 @@ import './App.css' -import { CommentItem, CommentListContainer, SubCommentData } from './Comment'; +import { CommentItem, CommentListContainer, CommentPagination, SubCommentData } from './Comment'; import CommentHeader from './CommentHeader'; import { Footer } from './Footer'; import { GalleryContent } from './Gallery'; @@ -197,6 +197,7 @@ function App() { showDelete: true, }} /> +
diff --git a/src/Comment.tsx b/src/Comment.tsx index 8432052..511c9ad 100644 --- a/src/Comment.tsx +++ b/src/Comment.tsx @@ -1,4 +1,6 @@ +import { Separator } from "./Separator"; import { AuthorData } from "./table"; +import { cn } from "./util/cn"; interface CommentDataBase { id: number; @@ -183,3 +185,80 @@ export function CommentReplySection({ comments }: { comments: SubCommentData[] }
); } + +// Define the props the component will accept +interface CommentPaginationProps { + currentPage: number; + maxPage: number; + onPageChange?: (page: number) => void; // Optional callback for page changes + onViewContent?: () => void; // Optional click handler for "본문 보기" + onCloseComments?: () => void; // Optional click handler for "댓글닫기" + onRefresh?: () => void; // Optional click handler for "새로고침" +} + +export const CommentPagination: React.FC = ({ + currentPage, + maxPage, + onViewContent, + onCloseComments, + onRefresh, +}) => { + const pageNumbers = Array.from({ length: maxPage }, (_, i) => i + 1); // Generate page numbers + + return ( +
+ {/* Page Number Section */} + {/* pt/pb values approximate vertical centering within the 69px height */} + {/* text-center on parent handles horizontal centering */} +
+ {pageNumbers.map((page) => ( + + {page} + + ))} + {/* Add other page numbers logic here if needed */} +
+ + {/* Buttons Section */} +
+ { + if (onViewContent) { + e.preventDefault(); // Prevent default anchor behavior if it's an action + onViewContent(); + } + // Allow default behavior if onViewContent is not provided and href is meaningful + }} + className="text-custom-gray-dark align-middle leading-[15px] inline-block text-[13px] font-bold font-apple no-underline hover:underline cursor-pointer" + > + 본문 보기 + + + + + +
+
+ ); +}; \ No newline at end of file