-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Pagination): with pagination fix hidden ellipsis (#3271)
- Loading branch information
1 parent
e3d933a
commit 47747f1
Showing
7 changed files
with
89 additions
and
17 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
docs/src/examples/addons/Pagination/Types/PaginationExampleCompact.js
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,16 @@ | ||
import React from 'react' | ||
import { Pagination } from 'semantic-ui-react' | ||
|
||
const PaginationExampleCompact = () => ( | ||
<Pagination | ||
boundaryRange={0} | ||
defaultActivePage={1} | ||
ellipsisItem={null} | ||
firstItem={null} | ||
lastItem={null} | ||
siblingRange={1} | ||
totalPages={10} | ||
/> | ||
) | ||
|
||
export default PaginationExampleCompact |
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 |
---|---|---|
@@ -1,29 +1,31 @@ | ||
import _ from 'lodash' | ||
import { createInnerPrefix, createInnerSuffix } from './suffixFactories' | ||
|
||
export const createSimpleRange = (start, end, pageFactory) => _.map(_.range(start, end + 1), pageFactory) | ||
export const createSimpleRange = (start, end, pageFactory) => | ||
_.map(_.range(start, end + 1), pageFactory) | ||
|
||
export const createComplexRange = (options, pageFactory) => { | ||
const { activePage, boundaryRange, siblingRange, totalPages } = options | ||
const { activePage, boundaryRange, hideEllipsis, siblingRange, totalPages } = options | ||
|
||
const ellipsisSize = hideEllipsis ? 0 : 1 | ||
const firstGroupEnd = boundaryRange | ||
const firstGroup = createSimpleRange(1, firstGroupEnd, pageFactory) | ||
|
||
const lastGroupStart = (totalPages + 1) - boundaryRange | ||
const lastGroupStart = totalPages + 1 - boundaryRange | ||
const lastGroup = createSimpleRange(lastGroupStart, totalPages, pageFactory) | ||
|
||
const innerGroupStart = Math.min( | ||
Math.max(activePage - siblingRange, firstGroupEnd + 2), | ||
lastGroupStart - 1 - (2 * siblingRange) - 1, | ||
Math.max(activePage - siblingRange, firstGroupEnd + ellipsisSize + 1), | ||
lastGroupStart - ellipsisSize - 2 * siblingRange - 1, | ||
) | ||
const innerGroupEnd = innerGroupStart + (2 * siblingRange) | ||
const innerGroupEnd = innerGroupStart + 2 * siblingRange | ||
const innerGroup = createSimpleRange(innerGroupStart, innerGroupEnd, pageFactory) | ||
|
||
return [ | ||
...firstGroup, | ||
createInnerPrefix(firstGroupEnd, innerGroupStart, pageFactory), | ||
!hideEllipsis && createInnerPrefix(firstGroupEnd, innerGroupStart, pageFactory), | ||
...innerGroup, | ||
createInnerSuffix(innerGroupEnd, lastGroupStart, pageFactory), | ||
!hideEllipsis && createInnerSuffix(innerGroupEnd, lastGroupStart, pageFactory), | ||
...lastGroup, | ||
].filter(Boolean) | ||
} |
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