Repository navigation
feat(ui): add Mosaic Pagination component #9738
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
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d3c2f38
feat(ui): add Mosaic Pagination component
alexcarpenter e4090ef
fix(ui): sanitize Pagination numeric props and label the page-size co…
alexcarpenter 2996d51
Merge branch 'main' into carp/mosaic-pagination
alexcarpenter 0b539a7
Merge branch 'main' into carp/mosaic-pagination
alexcarpenter dd01af6
chore(ui): address Pagination review nits
alexcarpenter d846175
refactor(ui): take xstyle on Pagination instead of className and style
alexcarpenter 2611063
feat(ui): use the Mosaic Select for the Pagination page size
alexcarpenter 4a16f60
Merge remote-tracking branch 'origin/main' into carp/mosaic-pagination
alexcarpenter 2d5e8f5
fix(ui): use the restructured foreground tokens in Pagination
alexcarpenter fe96131
fix(ui): size the Pagination page size options to match the trigger
alexcarpenter db99f7d
fix(ui): inset the Pagination page size options to the sm trigger text
alexcarpenter 868ce38
refactor(ui): give the Pagination page size label its own slot
alexcarpenter 934776d
feat(ui): take the Pagination page size label as a prop
alexcarpenter 599edb6
Merge remote-tracking branch 'origin/main' into carp/mosaic-pagination
alexcarpenter c9d14e2
refactor(ui): render the Pagination page size label with Text
alexcarpenter b6542e8
fix(ui): keep the pagination-label slot class on the Text label
alexcarpenter bdb06d4
fix(ui): drop invalid and duplicate Pagination page size options
alexcarpenter 9ad65e7
feat(ui): localize Pagination control labels and fill the gaps betwee…
alexcarpenter 53b92a4
chore(ui): retrigger CI for Pagination
alexcarpenter 72172d0
Merge remote-tracking branch 'origin/main' into carp/mosaic-pagination
alexcarpenter 5d59113
refactor(mosaic): move Pagination into @clerk/mosaic and mirror its c…
alexcarpenter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,2 @@ | ||
| --- | ||
| --- | ||
This file contains hidden or 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,2 @@ | ||
| export { Pagination } from './pagination'; | ||
| export type { PaginationProps } from './pagination'; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
This file contains hidden or 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,33 @@ | ||
| export type PageItem = number | 'start-ellipsis' | 'end-ellipsis'; | ||
|
|
||
| function range(start: number, end: number): number[] { | ||
| const pages: number[] = []; | ||
| for (let page = start; page <= end; page++) { | ||
| pages.push(page); | ||
| } | ||
| return pages; | ||
| } | ||
|
|
||
| export function getPageItems(page: number, pageCount: number, siblingCount: number): PageItem[] { | ||
| if (pageCount <= 1) { | ||
| return [1]; | ||
| } | ||
|
|
||
| const windowStart = Math.max(Math.min(page - siblingCount, pageCount - 2 * siblingCount - 2), 3); | ||
| const windowEnd = Math.min(Math.max(page + siblingCount, 2 * siblingCount + 3), pageCount - 2); | ||
|
|
||
| const items: PageItem[] = [1]; | ||
| if (windowStart > 3) { | ||
| items.push('start-ellipsis'); | ||
| } else if (pageCount > 3) { | ||
| items.push(2); | ||
| } | ||
| items.push(...range(windowStart, windowEnd)); | ||
| if (windowEnd < pageCount - 2) { | ||
| items.push('end-ellipsis'); | ||
| } else if (pageCount > 2) { | ||
| items.push(pageCount - 1); | ||
| } | ||
| items.push(pageCount); | ||
| return items; | ||
| } |
53 changes: 53 additions & 0 deletions
53
packages/mosaic/src/components/pagination/pagination.styles.ts
This file contains hidden or 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,53 @@ | ||
| import * as stylex from '@stylexjs/stylex'; | ||
|
|
||
| import { colorVars, space, typeScaleVars } from '../../tokens.stylex'; | ||
|
|
||
| export const styles = stylex.create({ | ||
| root: { | ||
| gap: space['4'], | ||
| alignItems: 'center', | ||
| display: 'flex', | ||
| flexWrap: 'wrap', | ||
| justifyContent: 'space-between', | ||
| }, | ||
| controls: { | ||
| gap: space['1'], | ||
| alignItems: 'center', | ||
| display: 'flex', | ||
| }, | ||
| hitTarget: { | ||
| position: 'relative', | ||
| '::after': { | ||
| insetBlock: 0, | ||
| insetInline: `calc(${space['1']} / -2)`, | ||
| content: '""', | ||
| position: 'absolute', | ||
| }, | ||
| }, | ||
| page: { | ||
| color: { | ||
| default: colorVars['--cl-color-foreground-secondary'], | ||
| ':where([aria-current="page"])': colorVars['--cl-color-foreground'], | ||
| }, | ||
| }, | ||
| ellipsis: { | ||
| alignItems: 'center', | ||
| color: colorVars['--cl-color-foreground-secondary'], | ||
| display: 'inline-flex', | ||
| justifyContent: 'center', | ||
| height: space['7'], | ||
| width: space['7'], | ||
| }, | ||
| pageSize: { | ||
| gap: space['2'], | ||
| alignItems: 'center', | ||
| display: 'flex', | ||
| }, | ||
| pageSizeOption: { | ||
| paddingBlock: 0, | ||
| paddingInline: space['2'], | ||
| fontSize: typeScaleVars['--cl-text-xs-size'], | ||
| lineHeight: typeScaleVars['--cl-text-xs-leading'], | ||
| minHeight: space['7'], | ||
| }, | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.