Skip to content

Commit 23fdc3c

Browse files
committed
Fix pagination story and pagebutton highlight
1 parent e92cbbf commit 23fdc3c

File tree

2 files changed

+20
-32
lines changed

2 files changed

+20
-32
lines changed
Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,53 @@
1-
import { action } from "@storybook/addon-actions"
21
import { Story } from "@storybook/react"
32
import { PaginationWidget, PaginationWidgetProps } from "./PaginationWidget"
3+
import { createPaginationRef } from "./utils"
44

55
export default {
66
title: "components/PaginationWidget",
77
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+
}
822
}
923

1024
const Template: Story<PaginationWidgetProps> = (
1125
args: PaginationWidgetProps,
1226
) => <PaginationWidget {...args} />
1327

14-
const defaultProps = {
15-
prevLabel: "Previous",
16-
nextLabel: "Next",
17-
onPrevClick: action("previous"),
18-
onNextClick: action("next"),
19-
onPageClick: action("clicked"),
20-
}
21-
2228
export const UnknownPageNumbers = Template.bind({})
2329
UnknownPageNumbers.args = {
24-
...defaultProps,
30+
numRecords: undefined
2531
}
2632

2733
export const LessThan8Pages = Template.bind({})
2834
LessThan8Pages.args = {
29-
...defaultProps,
3035
numRecords: 84,
31-
numRecordsPerPage: 12,
32-
activePage: 1,
3336
}
3437

3538
export const MoreThan8Pages = Template.bind({})
36-
MoreThan8Pages.args = {
37-
...defaultProps,
38-
numRecords: 200,
39-
numRecordsPerPage: 12,
40-
activePage: 1,
41-
}
4239

4340
export const MoreThan7PagesWithActivePageCloseToStart = Template.bind({})
4441
MoreThan7PagesWithActivePageCloseToStart.args = {
45-
...defaultProps,
46-
numRecords: 200,
47-
numRecordsPerPage: 12,
48-
activePage: 2,
42+
paginationRef: createPaginationRef({ page: 2, limit: 12 })
4943
}
5044

5145
export const MoreThan7PagesWithActivePageFarFromBoundaries = Template.bind({})
5246
MoreThan7PagesWithActivePageFarFromBoundaries.args = {
53-
...defaultProps,
54-
numRecords: 200,
55-
numRecordsPerPage: 12,
56-
activePage: 4,
47+
paginationRef: createPaginationRef({ page: 4, limit: 12 })
5748
}
5849

5950
export const MoreThan7PagesWithActivePageCloseToEnd = Template.bind({})
6051
MoreThan7PagesWithActivePageCloseToEnd.args = {
61-
...defaultProps,
62-
numRecords: 200,
63-
numRecordsPerPage: 12,
64-
activePage: 17,
52+
paginationRef: createPaginationRef({ page: 17, limit: 12 })
6553
}

site/src/components/PaginationWidget/PaginationWidget.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const PaginationWidget = ({
6666
<Cond>
6767
{buildPagedList(numPages, currentPage).map((page) =>
6868
typeof page !== "number" ? (
69-
<PageButton key={`Page${page}`} placeholder="..." disabled />
69+
<PageButton key={`Page${page}`} activePage={currentPage} placeholder="..." disabled />
7070
) : (
7171
<PageButton
7272
key={`Page${page}`}

0 commit comments

Comments
 (0)