-
Notifications
You must be signed in to change notification settings - Fork 1
✨ feat: 페이지네이션 구현 #25
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
569f574
🖼️ feat: 페이지네이션 아이콘4장 추가
697f61e
📁 chore : Pagination 컴포넌트 파일 생성
112bcbe
✨ feat: Pagination 컴포넌트 기본 구조 및 Props 적용
17f2bce
✨ feat: 페이지 번호 버튼 구현 및 Tailwind 스타일 적용
8a282a1
✨ feat: 이전/다음 버튼 포함 페이지네이션 기능 완성 및 Tailwind 스타일 적용
c8738a4
♻️ refactor: 오른쪽 회색 화살표 제거 및 마지막 페이지에서 화살표 숨김 처리
752294b
✨ feat: 페이지네이션 7개 단위 그룹으로 이동 구현
5385973
Merge branch 'develop' of https://github.com/codeit-6team/The-julge i…
f3b12ca
✨ feat: 페이지네이션 피드백 반영 후 수정
a313932
✨ feat: 페이지네이션 피드백 2차 반영
3bdfda4
✨feat : 페이지네이션 피드팩 2차 수정
124ae07
Merge branch 'develop' of https://github.com/codeit-6team/The-julge i…
8ebe3c0
Merge branch 'develop' of https://github.com/codeit-6team/The-julge i…
2e94368
✨feat:페이지네이션 2차 피드백 반영 후 수정
212604e
🎨style: 스타일 수정
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Moon-ju-young marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| 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; | ||
| setCurrentPage: React.Dispatch<React.SetStateAction<number>>; | ||
| } | ||
|
|
||
| export default function Pagination({ | ||
| totalPages, | ||
| currentPage, | ||
| setCurrentPage, | ||
| }: Props) { | ||
| const handleClick = (page: number) => { | ||
| setCurrentPage(page); | ||
| }; | ||
|
|
||
| const range = (start: number, end: number) => { | ||
| return Array.from({ length: end - start + 1 }, (_, i) => start + i); | ||
| }; | ||
|
|
||
| let start = 1; | ||
| let end = 7; | ||
|
|
||
| if (currentPage > 4) { | ||
| start = currentPage - 3; | ||
| end = currentPage + 3; | ||
| } | ||
|
|
||
| if (end > totalPages) { | ||
| end = totalPages; | ||
| start = Math.max(end - 6, 1); | ||
| } | ||
|
|
||
| const pageNumbers = range(start, end); | ||
|
|
||
| return ( | ||
| <div className="flex items-center justify-center gap-20 py-12"> | ||
| {/* 왼쪽 화살표 */} | ||
| {totalPages > 7 && ( | ||
| <button type="button" onClick={() => handleClick(1)}> | ||
| <img | ||
| src={currentPage === 1 ? ArrowLeftGray : ArrowLeft} | ||
| alt="이전" | ||
| className="size-20" | ||
| /> | ||
| </button> | ||
| )} | ||
|
|
||
| {/* 페이지 버튼들 */} | ||
| <div className="flex gap-4 md:gap-2"> | ||
| {pageNumbers.map((page) => ( | ||
| <button | ||
| key={page} | ||
| type="button" | ||
| onClick={() => handleClick(page)} | ||
| className={`flex size-32 items-center justify-center rounded-sm text-caption md:size-40 md:text-body2 ${ | ||
| currentPage === page | ||
| ? 'bg-red-30 text-white' | ||
| : 'bg-white text-black' | ||
| }`} | ||
| > | ||
| {page} | ||
| </button> | ||
| ))} | ||
| </div> | ||
|
|
||
| {/* 오른쪽 화살표 */} | ||
| {totalPages > 7 && currentPage < totalPages && ( | ||
| <button type="button" onClick={() => handleClick(totalPages)}> | ||
| <img src={ArrowRight} alt="다음" className="size-20" /> | ||
| </button> | ||
| )} | ||
| </div> | ||
| ); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.