Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

Commit

Permalink
fixup! feat: Add Pagination component
Browse files Browse the repository at this point in the history
  • Loading branch information
rafenden committed Nov 1, 2019
1 parent 99d2a00 commit 01280f1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/pagination/Pagination.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const StyledPagesTruncation = styled('span')`
`

function Pagination({ totalPages, activePage, onPageClick, getPageUrl }) {
const visiblePieces = computeVisiblePieces(totalPages, activePage, 5)
const visiblePieces = computeVisiblePieces(totalPages, activePage)

if (totalPages === 1) {
return null
Expand Down
5 changes: 3 additions & 2 deletions src/pagination/computeVisiblePieces.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
DEFAULT_MAX_PAGE_NUMBER_LINKS,
PAGINATION_PIECE_ELLIPSIS,
PAGINATION_PIECE_NEXT,
PAGINATION_PIECE_PAGE_NUMBER,
Expand All @@ -7,8 +8,8 @@ import {

function computeVisiblePieces(
numberOfPages,
activePage = 1,
maxPageNumbers = 5
activePage,
maxPageNumbers = DEFAULT_MAX_PAGE_NUMBER_LINKS
) {
const visiblePieces = []
let lowerLimit = activePage
Expand Down
2 changes: 2 additions & 0 deletions src/pagination/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ export const PAGINATION_PIECE_PREVIOUS = 'previous'
export const PAGINATION_PIECE_ELLIPSIS = 'ellipsis'
export const PAGINATION_PIECE_PAGE_NUMBER = 'page-number'
export const PAGINATION_PIECE_NEXT = 'next'

export const DEFAULT_MAX_PAGE_NUMBER_LINKS = 5

0 comments on commit 01280f1

Please sign in to comment.