Skip to content

Commit c8522d3

Browse files
authored
Adds stories for the Pagination component (#3037)
* adds stories for the Pagination component * adds Storybook link to docs frontmatter * Update generated/components.json * adds Pagination to Storybook test allowList --------- Co-authored-by: mperrotti <[email protected]>
1 parent 04d9db0 commit c8522d3

File tree

5 files changed

+72
-1
lines changed

5 files changed

+72
-1
lines changed

docs/content/Pagination.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: Pagination
33
componentId: pagination
44
description: Use Pagination to display a sequence of links that allow navigation to discrete, related pages.
55
source: https://github.com/primer/react/blob/main/src/Pagination/Pagination.tsx
6+
storybook: '/react/storybook?path=/story/components-pagination-features--hide-page-numbers'
67
status: Alpha
78
---
89

generated/components.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3106,7 +3106,12 @@
31063106
"name": "Pagination",
31073107
"status": "alpha",
31083108
"a11yReviewed": false,
3109-
"stories": [],
3109+
"stories": [
3110+
{
3111+
"id": "components-pagination--default",
3112+
"code": "() => (\n <Pagination\n pageCount={15}\n currentPage={2}\n onPageChange={(e) => e.preventDefault()}\n />\n)"
3113+
}
3114+
],
31103115
"props": [
31113116
{
31123117
"name": "currentPage",
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react'
2+
import {Meta} from '@storybook/react'
3+
import {ComponentProps} from '../utils/types'
4+
import Pagination from './Pagination'
5+
6+
export default {
7+
title: 'Components/Pagination/Features',
8+
component: Pagination,
9+
} as Meta<ComponentProps<typeof Pagination>>
10+
11+
export const LargerPageCountMargin = () => (
12+
<Pagination pageCount={15} currentPage={5} marginPageCount={4} onPageChange={e => e.preventDefault()} />
13+
)
14+
15+
export const HidePageNumbers = () => (
16+
<Pagination pageCount={15} currentPage={5} showPages={false} onPageChange={e => e.preventDefault()} />
17+
)
18+
19+
export const HigherSurroundingPageCount = () => (
20+
<Pagination pageCount={15} currentPage={5} surroundingPageCount={4} onPageChange={e => e.preventDefault()} />
21+
)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React from 'react'
2+
import {Meta, Story} from '@storybook/react'
3+
import {ComponentProps} from '../utils/types'
4+
import Pagination from './Pagination'
5+
6+
export default {
7+
title: 'Components/Pagination',
8+
component: Pagination,
9+
} as Meta<ComponentProps<typeof Pagination>>
10+
11+
export const Default = () => <Pagination pageCount={15} currentPage={2} onPageChange={e => e.preventDefault()} />
12+
13+
export const Playground: Story<ComponentProps<typeof Pagination>> = args => (
14+
<Pagination onPageChange={e => e.preventDefault()} {...args} />
15+
)
16+
17+
Playground.args = {
18+
currentPage: 5,
19+
marginPageCount: 1,
20+
pageCount: 15,
21+
showPages: true,
22+
surroundingPageCount: 2,
23+
}
24+
Playground.argTypes = {
25+
hrefBuilder: {
26+
control: false,
27+
table: {
28+
disable: true,
29+
},
30+
},
31+
onPageChange: {
32+
control: false,
33+
table: {
34+
disable: true,
35+
},
36+
},
37+
theme: {
38+
control: false,
39+
table: {
40+
disable: true,
41+
},
42+
},
43+
}

src/__tests__/storybook.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const allowlist = [
2727
'FilteredActionList',
2828
'Link',
2929
'Pagehead',
30+
'Pagination',
3031
'Radio',
3132
'RadioGroup',
3233
'Select',

0 commit comments

Comments
 (0)