-
Notifications
You must be signed in to change notification settings - Fork 2
[#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
Conversation
…hared-component-pagination
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
늘 많은 코드임에도 불구하고 깔끔하게 잘 짜주시네요..!
천천히 잘 읽어보았습니다! 고생하셨습니다 💯
label?: string | ||
children?: React.ReactNode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
label 이 아닌 children 으로 넘겨주는 것이 자식으로 받는 요소의 형식(?)에 관계없이 넘겨주기 좋겠네요..!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네 맞아요 특히 아이콘을 프롭으로 넘기려니까 스타일도 바깥에서 커스텀하기도 어렵고 영 귀찮더라구요 ㅋㅋ
children 으로 의도치 않게 많은 요소들이 버튼에 넘겨지는 것이 염려되어 처음에 label 과 icons 프롭스 넘기는 식으로 설계했는데,
역시 유연한게 짱인거 같아요
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 | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
페이지 계산하는 게 꽤 복잡해보이는데 잘 해주셨네요...!🥺
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기초 프로젝트에서 비슷한 구조의 페이지네이션 훅을 짠게 있어서 복붙했어요 ㅋㅋ
export interface PaginationState { | ||
currentPage: number // 현재 페이지 | ||
pageButtons: number[] // 현재 페이지 그룹의 버튼 목록 | ||
hasNextPageGroup: boolean // 다음 페이지 그룹 존재 여부 | ||
hasPreviousPageGroup: boolean // 이전 페이지 그룹 존재 여부 | ||
goToPage: (page: number) => void // 특정 페이지로 이동 | ||
goToNextPageGroup: () => void // 다음 페이지 그룹으로 이동 | ||
goToPreviousPageGroup: () => void // 이전 페이지 그룹으로 이동 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
타입 정리 또한 깔끔하게 늘 잘해주셔서 개발할 때 편한 것 같아요 !! 감사합니다 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
감사합니다 ㅎㅎ
📌 PR 템플릿
🏷️ PR 타입 (PR Type)
📝 요약 (Summary)
페이지네이션 컴포넌트와 훅을 구현했습니다.
🔍 상세 내용 (Describe your changes)
🔗 관련 이슈 또는 링크 (Issue Number or Link)
✅ 체크리스트 (Checklist)
📸 스크린샷 (선택 사항)
2024-11-28.20.29.18.mov
📝 기타 사항