Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/App.tsx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❗ 해당 파일에서 충돌이 일어나는 이유가 최신 develop branch에서 merge를 안해와서 그런 것 같습니다~ pr merge 하기 전에 최신 변경사항 반영 해주세용

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function App() {
return (
<>
<h1 className="text-3xl font-bold underline">hi</h1>
</>
<div>
<h1>hi</h1>
</div>
);
}
3 changes: 3 additions & 0 deletions src/assets/icons/arrow-left-gray.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/assets/icons/arrow-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icons/arrow-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions src/components/common/pagination/Pagination.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import ArrowLeft from '../../../assets/icons/arrow-left.svg';
import ArrowLeftGray from '../../../assets/icons/arrow-left-gray.svg';
import ArrowRight from '../../../assets/icons/arrow-right.svg';

interface Props {
totalPages: number;
currentPage: number;
onChangePage: (pageNumber: number) => void;
}

export default function Pagination({
totalPages,
currentPage,
onChangePage,
}: Props) {
const groupSize = 7;
const currentGroup = Math.floor((currentPage - 1) / groupSize);
const groupStart = currentGroup * groupSize + 1;
const groupEnd = Math.min(groupStart + groupSize - 1, totalPages);

const renderPageNumbers = () => {
return Array.from(
{ length: groupEnd - groupStart + 1 },
(_, index) => groupStart + index,
).map((pageNumber) => (
<button
key={pageNumber}
type="button"
onClick={() => onChangePage(pageNumber)}
className={`w-10 h-10 rounded flex items-center justify-center text-sm ${
currentPage === pageNumber
? 'text-white font-bold'
: 'text-black hover:bg-gray-100'
}`}
style={{
backgroundColor: currentPage === pageNumber ? '#FF8D72' : '#ffffff',
}}
>
{pageNumber}
</button>
));
};

return (
<div className="flex items-center justify-center gap-4">
{/* 이전 그룹 이동 */}
{totalPages > groupSize && groupStart > 1 && (
<button type="button" onClick={() => onChangePage(groupStart - 1)}>
<img
src={groupStart - 1 === 1 ? ArrowLeftGray : ArrowLeft}
alt="이전 페이지 그룹"
className="w-5 h-5"
/>
</button>
)}

{/* 페이지 번호 */}
<div className="flex gap-1">{renderPageNumbers()}</div>

{/* 다음 그룹 이동 */}
{totalPages > groupSize && groupEnd < totalPages && (
<button type="button" onClick={() => onChangePage(groupEnd + 1)}>
<img src={ArrowRight} alt="다음 페이지 그룹" className="w-5 h-5" />
</button>
)}
</div>
);
}