Skip to content

[#99] ✨ shared 컴포넌트 Pagination 개발 #133

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 13 commits into from
Nov 28, 2024

Conversation

KingNono1030
Copy link
Contributor

@KingNono1030 KingNono1030 commented Nov 28, 2024

📌 PR 템플릿

🏷️ PR 타입 (PR Type)

아래 해당 사항에 체크해 주세요.

  • 🐛 버그 수정 (Bugfix)
  • ✨ 기능 개발 (Feature)
  • 🎨 코드 스타일 변경 (Code style update) - 포매팅, 로컬 변수 등
  • ♻️ 리팩토링 (Refactoring) - 기능 변화 없음, API 변경 없음
  • 🛠️ 빌드 관련 변경 (Build related changes)
  • 📝 문서 내용 변경 (Documentation)
  • 🔄 기타 (Other) - 설명 작성

📝 요약 (Summary)

PR의 목적과 간단한 설명을 적어주세요.

페이지네이션 컴포넌트와 훅을 구현했습니다.


🔍 상세 내용 (Describe your changes)

변경 사항을 구체적으로 작성해 주세요.


🔗 관련 이슈 또는 링크 (Issue Number or Link)

이슈 번호나 관련 링크가 있다면 추가해 주세요.


✅ 체크리스트 (Checklist)

PR 작성 시 아래 사항들을 점검해 주세요.

  • 빌드가 성공적으로 되었나요?
  • 코드에 주석을 추가했나요?
  • 모든 테스트가 통과했나요?
  • 관련 문서가 업데이트되었나요?

📸 스크린샷 (선택 사항)

변경 사항이 UI와 관련이 있다면 스크린샷을 추가해 주세요.

2024-11-28.20.29.18.mov

📝 기타 사항

PR과 관련된 기타 사항이 있다면 적어주세요.

@KingNono1030 KingNono1030 self-assigned this Nov 28, 2024
@KingNono1030 KingNono1030 linked an issue Nov 28, 2024 that may be closed by this pull request
@KingNono1030 KingNono1030 marked this pull request as ready for review November 28, 2024 11:54
Copy link
Contributor

@yellowjang yellowjang left a comment

Choose a reason for hiding this comment

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

늘 많은 코드임에도 불구하고 깔끔하게 잘 짜주시네요..!
천천히 잘 읽어보았습니다! 고생하셨습니다 💯

Comment on lines -4 to +5
label?: string
children?: React.ReactNode
Copy link
Contributor

Choose a reason for hiding this comment

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

label 이 아닌 children 으로 넘겨주는 것이 자식으로 받는 요소의 형식(?)에 관계없이 넘겨주기 좋겠네요..!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네 맞아요 특히 아이콘을 프롭으로 넘기려니까 스타일도 바깥에서 커스텀하기도 어렵고 영 귀찮더라구요 ㅋㅋ
children 으로 의도치 않게 많은 요소들이 버튼에 넘겨지는 것이 염려되어 처음에 label 과 icons 프롭스 넘기는 식으로 설계했는데,
역시 유연한게 짱인거 같아요

Comment on lines +20 to +29
const totalPages = Math.ceil(totalItems / itemsPerPage) // 총 페이지 수
const totalGroups = Math.ceil(totalPages / buttonsPerPage) // 총 그룹 수
const [currentPage, setCurrentPage] = useState(1) // 현재 페이지
const [currentGroupIndex, setCurrentGroupIndex] = useState(0) // 현재 페이지 그룹 인덱스

const firstPageInGroup = currentGroupIndex * buttonsPerPage + 1
const lastPageInGroup = Math.min(
firstPageInGroup + buttonsPerPage - 1,
totalPages
)
Copy link
Contributor

Choose a reason for hiding this comment

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

페이지 계산하는 게 꽤 복잡해보이는데 잘 해주셨네요...!🥺

Copy link
Contributor Author

Choose a reason for hiding this comment

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

기초 프로젝트에서 비슷한 구조의 페이지네이션 훅을 짠게 있어서 복붙했어요 ㅋㅋ

Comment on lines +1 to +8
export interface PaginationState {
currentPage: number // 현재 페이지
pageButtons: number[] // 현재 페이지 그룹의 버튼 목록
hasNextPageGroup: boolean // 다음 페이지 그룹 존재 여부
hasPreviousPageGroup: boolean // 이전 페이지 그룹 존재 여부
goToPage: (page: number) => void // 특정 페이지로 이동
goToNextPageGroup: () => void // 다음 페이지 그룹으로 이동
goToPreviousPageGroup: () => void // 이전 페이지 그룹으로 이동
Copy link
Contributor

Choose a reason for hiding this comment

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

타입 정리 또한 깔끔하게 늘 잘해주셔서 개발할 때 편한 것 같아요 !! 감사합니다 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

감사합니다 ㅎㅎ

@KingNono1030 KingNono1030 merged commit 81b2332 into dev Nov 28, 2024
3 of 4 checks passed
@KingNono1030 KingNono1030 deleted the feat/shared-component-pagination branch November 28, 2024 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] [shared 컴포넌트] Pagination
2 participants