|
1 |
| -import { action } from "@storybook/addon-actions" |
2 | 1 | import { Story } from "@storybook/react"
|
3 | 2 | import { PaginationWidget, PaginationWidgetProps } from "./PaginationWidget"
|
| 3 | +import { createPaginationRef } from "./utils" |
4 | 4 |
|
5 | 5 | export default {
|
6 | 6 | title: "components/PaginationWidget",
|
7 | 7 | component: PaginationWidget,
|
| 8 | + argTypes: { |
| 9 | + prevLabel: { |
| 10 | + defaultValue: "Previous" |
| 11 | + }, |
| 12 | + nextLabel: { |
| 13 | + defaultValue: "Next" |
| 14 | + }, |
| 15 | + paginationRef: { |
| 16 | + defaultValue: createPaginationRef({ page: 1, limit: 12 }) |
| 17 | + }, |
| 18 | + numRecords: { |
| 19 | + defaultValue: 200 |
| 20 | + } |
| 21 | + } |
8 | 22 | }
|
9 | 23 |
|
10 | 24 | const Template: Story<PaginationWidgetProps> = (
|
11 | 25 | args: PaginationWidgetProps,
|
12 | 26 | ) => <PaginationWidget {...args} />
|
13 | 27 |
|
14 |
| -const defaultProps = { |
15 |
| - prevLabel: "Previous", |
16 |
| - nextLabel: "Next", |
17 |
| - onPrevClick: action("previous"), |
18 |
| - onNextClick: action("next"), |
19 |
| - onPageClick: action("clicked"), |
20 |
| -} |
21 |
| - |
22 | 28 | export const UnknownPageNumbers = Template.bind({})
|
23 | 29 | UnknownPageNumbers.args = {
|
24 |
| - ...defaultProps, |
| 30 | + numRecords: undefined |
25 | 31 | }
|
26 | 32 |
|
27 | 33 | export const LessThan8Pages = Template.bind({})
|
28 | 34 | LessThan8Pages.args = {
|
29 |
| - ...defaultProps, |
30 | 35 | numRecords: 84,
|
31 |
| - numRecordsPerPage: 12, |
32 |
| - activePage: 1, |
33 | 36 | }
|
34 | 37 |
|
35 | 38 | export const MoreThan8Pages = Template.bind({})
|
36 |
| -MoreThan8Pages.args = { |
37 |
| - ...defaultProps, |
38 |
| - numRecords: 200, |
39 |
| - numRecordsPerPage: 12, |
40 |
| - activePage: 1, |
41 |
| -} |
42 | 39 |
|
43 | 40 | export const MoreThan7PagesWithActivePageCloseToStart = Template.bind({})
|
44 | 41 | MoreThan7PagesWithActivePageCloseToStart.args = {
|
45 |
| - ...defaultProps, |
46 |
| - numRecords: 200, |
47 |
| - numRecordsPerPage: 12, |
48 |
| - activePage: 2, |
| 42 | + paginationRef: createPaginationRef({ page: 2, limit: 12 }) |
49 | 43 | }
|
50 | 44 |
|
51 | 45 | export const MoreThan7PagesWithActivePageFarFromBoundaries = Template.bind({})
|
52 | 46 | MoreThan7PagesWithActivePageFarFromBoundaries.args = {
|
53 |
| - ...defaultProps, |
54 |
| - numRecords: 200, |
55 |
| - numRecordsPerPage: 12, |
56 |
| - activePage: 4, |
| 47 | + paginationRef: createPaginationRef({ page: 4, limit: 12 }) |
57 | 48 | }
|
58 | 49 |
|
59 | 50 | export const MoreThan7PagesWithActivePageCloseToEnd = Template.bind({})
|
60 | 51 | MoreThan7PagesWithActivePageCloseToEnd.args = {
|
61 |
| - ...defaultProps, |
62 |
| - numRecords: 200, |
63 |
| - numRecordsPerPage: 12, |
64 |
| - activePage: 17, |
| 52 | + paginationRef: createPaginationRef({ page: 17, limit: 12 }) |
65 | 53 | }
|
0 commit comments