-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pagination): improves pagination behaviour
Length of pagination stays the same. End buttons disable when appropriate. Option to hide if only on page. fix #316
- Loading branch information
1 parent
2da5c13
commit 923458e
Showing
3 changed files
with
164 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,72 @@ | ||
import { Meta, Story } from '@storybook/react' | ||
import React, { useState } from 'react' | ||
import { Pagination } from '.' | ||
import { Pagination, PaginationProps } from '.' | ||
import { Divider } from '../Divider' | ||
import { Label } from '../Label' | ||
import { Radio, RadioGroup } from '../RadioGroup' | ||
import { Stack } from '../Stack' | ||
|
||
export default { | ||
title: 'Components/Pagination', | ||
component: Pagination, | ||
} as Meta | ||
|
||
export const Default: Story = (args) => <Pagination count={10} {...args} /> | ||
|
||
export const Controlled: Story = (args) => { | ||
const Template: Story<PaginationProps> = (args) => { | ||
const [page, setPage] = useState(1) | ||
return <Pagination count={10} page={page} onPageChange={setPage} {...args} /> | ||
return <Pagination {...args} page={page} onPageChange={setPage} /> | ||
} | ||
|
||
export const Default = Template.bind({}) | ||
Default.args = { | ||
totalPages: 10, | ||
} | ||
|
||
export const ManyPages = Template.bind({}) | ||
ManyPages.args = { | ||
totalPages: 100, | ||
} | ||
|
||
export const BoundaryCondition = Template.bind({}) | ||
BoundaryCondition.args = { | ||
totalPages: 14, | ||
} | ||
|
||
export const ManyPages: Story = () => <Pagination count={100} page={75} /> | ||
export const ChangePadding = Template.bind({}) | ||
ChangePadding.args = { | ||
totalPages: 20, | ||
boundaryCount: 3, | ||
siblingCount: 2, | ||
} | ||
|
||
export const LayoutOptions = Template.bind({}) | ||
LayoutOptions.args = { | ||
totalPages: 20, | ||
align: 'center', | ||
spacing: 'small', | ||
} | ||
|
||
export const Single: Story<PaginationProps> = (args) => { | ||
const [single, setSingle] = useState('show') | ||
|
||
return ( | ||
<Stack> | ||
<Label>Single Prop</Label> | ||
<RadioGroup | ||
orientation="horizontal" | ||
value={single} | ||
onValueChange={setSingle} | ||
> | ||
<Radio value="show" label="show" /> | ||
<Radio value="hide" label="hide" /> | ||
<Radio value="none" label="none" /> | ||
</RadioGroup> | ||
<Divider /> | ||
<Pagination | ||
totalPages={1} | ||
page={1} | ||
single={single as PaginationProps['single']} | ||
/> | ||
<Divider /> | ||
</Stack> | ||
) | ||
} |
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