-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: refactoring Pagination component (#2837)
- Loading branch information
1 parent
310480a
commit adb5831
Showing
24 changed files
with
1,318 additions
and
857 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,43 @@ | ||
import React, { useContext } from 'react'; | ||
import { useMediaQuery } from 'react-responsive'; | ||
import PaginationContext from './PaginationContext'; | ||
import { ELLIPSIS } from './constants'; | ||
import { | ||
PreviousPageButton, | ||
NextPageButton, | ||
PageOfCountButton, | ||
PageButton, | ||
Ellipsis, | ||
} from './subcomponents'; | ||
import breakpoints from '../utils/breakpoints'; | ||
import newId from '../utils/newId'; | ||
|
||
function PaginationPages() { | ||
const { displayPages } = useContext(PaginationContext); | ||
const isMobile = useMediaQuery({ maxWidth: breakpoints.extraSmall.maxWidth }); | ||
|
||
if (isMobile) { | ||
return <PageOfCountButton />; | ||
} | ||
|
||
return ( | ||
<> | ||
{displayPages.map((pageIndex) => { | ||
if (pageIndex === ELLIPSIS) { | ||
return <Ellipsis key={newId('pagination-ellipsis-')} />; | ||
} | ||
return <PageButton key={pageIndex} pageNum={pageIndex + 1} />; | ||
})} | ||
</> | ||
); | ||
} | ||
|
||
export default function DefaultPagination() { | ||
return ( | ||
<ul className="pagination"> | ||
<PreviousPageButton /> | ||
<PaginationPages /> | ||
<NextPageButton /> | ||
</ul> | ||
); | ||
} |
This file contains 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,11 @@ | ||
import React from 'react'; | ||
import { PreviousPageButton, NextPageButton } from './subcomponents'; | ||
|
||
export default function MinimalPagination() { | ||
return ( | ||
<ul className="pagination"> | ||
<PreviousPageButton /> | ||
<NextPageButton /> | ||
</ul> | ||
); | ||
} |
Oops, something went wrong.