File tree Expand file tree Collapse file tree 6 files changed +36
-38
lines changed Expand file tree Collapse file tree 6 files changed +36
-38
lines changed Original file line number Diff line number Diff line change @@ -13,10 +13,10 @@ import { useTheme } from "@emotion/react";
13
13
14
14
type NavProps = {
15
15
currentPage : number ;
16
- onChange : ( newPage : number ) => void ;
16
+ onPageChange : ( newPage : number ) => void ;
17
17
} ;
18
18
19
- export function LeftNavButton ( { currentPage, onChange } : NavProps ) {
19
+ export function LeftNavButton ( { currentPage, onPageChange } : NavProps ) {
20
20
const isFirstPage = currentPage <= 1 ;
21
21
22
22
return (
@@ -26,7 +26,7 @@ export function LeftNavButton({ currentPage, onChange }: NavProps) {
26
26
aria-label = "Previous page"
27
27
onClick = { ( ) => {
28
28
if ( ! isFirstPage ) {
29
- onChange ( currentPage - 1 ) ;
29
+ onPageChange ( currentPage - 1 ) ;
30
30
}
31
31
} }
32
32
>
@@ -35,7 +35,7 @@ export function LeftNavButton({ currentPage, onChange }: NavProps) {
35
35
) ;
36
36
}
37
37
38
- export function RightNavButton ( { currentPage, onChange } : NavProps ) {
38
+ export function RightNavButton ( { currentPage, onPageChange } : NavProps ) {
39
39
const isLastPage = currentPage <= 1 ;
40
40
41
41
return (
@@ -45,7 +45,7 @@ export function RightNavButton({ currentPage, onChange }: NavProps) {
45
45
aria-label = "Previous page"
46
46
onClick = { ( ) => {
47
47
if ( ! isLastPage ) {
48
- onChange ( currentPage + 1 ) ;
48
+ onPageChange ( currentPage + 1 ) ;
49
49
}
50
50
} }
51
51
>
Original file line number Diff line number Diff line change @@ -5,9 +5,9 @@ const meta: Meta<typeof PaginationWidgetBase> = {
5
5
title : "components/PaginationWidgetBase" ,
6
6
component : PaginationWidgetBase ,
7
7
args : {
8
- page : 1 ,
9
- limit : 12 ,
10
- count : 200 ,
8
+ currentPage : 1 ,
9
+ pageSize : 12 ,
10
+ totalRecords : 200 ,
11
11
} ,
12
12
} ;
13
13
@@ -17,19 +17,17 @@ type Story = StoryObj<typeof PaginationWidgetBase>;
17
17
export const MoreThan8Pages : Story = { } ;
18
18
19
19
export const LessThan8Pages : Story = {
20
- args : {
21
- count : 84 ,
22
- } ,
20
+ args : { totalRecords : 84 } ,
23
21
} ;
24
22
25
23
export const MoreThan7PagesWithActivePageCloseToStart : Story = {
26
- args : { page : 2 , limit : 12 } ,
24
+ args : { currentPage : 2 , pageSize : 12 } ,
27
25
} ;
28
26
29
27
export const MoreThan7PagesWithActivePageFarFromBoundaries : Story = {
30
- args : { page : 4 , limit : 12 } ,
28
+ args : { currentPage : 4 , pageSize : 12 } ,
31
29
} ;
32
30
33
31
export const MoreThan7PagesWithActivePageCloseToEnd : Story = {
34
- args : { page : 17 , limit : 12 } ,
32
+ args : { currentPage : 17 , pageSize : 12 } ,
35
33
} ;
Original file line number Diff line number Diff line change @@ -6,21 +6,21 @@ import { buildPagedList } from "./utils";
6
6
import { LeftNavButton , RightNavButton } from "./PaginationNavButtons" ;
7
7
8
8
export type PaginationWidgetBaseProps = {
9
- count : number ;
10
- page : number ;
11
- limit : number ;
12
- onChange : ( newPage : number ) => void ;
9
+ currentPage : number ;
10
+ pageSize : number ;
11
+ totalRecords : number ;
12
+ onPageChange : ( newPage : number ) => void ;
13
13
} ;
14
14
15
15
export const PaginationWidgetBase = ( {
16
- count ,
17
- limit ,
18
- onChange ,
19
- page : currentPage ,
16
+ currentPage ,
17
+ pageSize ,
18
+ totalRecords ,
19
+ onPageChange ,
20
20
} : PaginationWidgetBaseProps ) => {
21
21
const theme = useTheme ( ) ;
22
22
const isMobile = useMediaQuery ( theme . breakpoints . down ( "md" ) ) ;
23
- const totalPages = Math . ceil ( count / limit ) ;
23
+ const totalPages = Math . ceil ( totalRecords / pageSize ) ;
24
24
25
25
if ( totalPages < 2 ) {
26
26
return null ;
@@ -37,7 +37,7 @@ export const PaginationWidgetBase = ({
37
37
columnGap : "6px" ,
38
38
} }
39
39
>
40
- < LeftNavButton currentPage = { currentPage } onChange = { onChange } />
40
+ < LeftNavButton currentPage = { currentPage } onPageChange = { onPageChange } />
41
41
42
42
{ isMobile ? (
43
43
< NumberedPageButton
@@ -49,11 +49,11 @@ export const PaginationWidgetBase = ({
49
49
< PaginationRow
50
50
currentPage = { currentPage }
51
51
totalPages = { totalPages }
52
- onChange = { onChange }
52
+ onChange = { onPageChange }
53
53
/>
54
54
) }
55
55
56
- < RightNavButton currentPage = { currentPage } onChange = { onChange } />
56
+ < RightNavButton currentPage = { currentPage } onPageChange = { onPageChange } />
57
57
</ div >
58
58
) ;
59
59
} ;
Original file line number Diff line number Diff line change @@ -133,10 +133,10 @@ export const AuditPageView: FC<AuditPageViewProps> = ({
133
133
134
134
{ count !== undefined && (
135
135
< PaginationWidgetBase
136
- count = { count }
137
- limit = { limit }
138
- onChange = { onPageChange }
139
- page = { page }
136
+ totalRecords = { count }
137
+ pageSize = { limit }
138
+ onPageChange = { onPageChange }
139
+ currentPage = { page }
140
140
/>
141
141
) }
142
142
</ Cond >
Original file line number Diff line number Diff line change @@ -102,10 +102,10 @@ export const UsersPageView: FC<React.PropsWithChildren<UsersPageViewProps>> = ({
102
102
103
103
{ count && (
104
104
< PaginationWidgetBase
105
- count = { count }
106
- limit = { limit }
107
- onChange = { onPageChange }
108
- page = { page }
105
+ totalRecords = { count }
106
+ pageSize = { limit }
107
+ onPageChange = { onPageChange }
108
+ currentPage = { page }
109
109
/>
110
110
) }
111
111
</ >
Original file line number Diff line number Diff line change @@ -161,10 +161,10 @@ export const WorkspacesPageView = ({
161
161
162
162
{ count !== undefined && (
163
163
< PaginationWidgetBase
164
- count = { count }
165
- limit = { limit }
166
- onChange = { onPageChange }
167
- page = { page }
164
+ totalRecords = { count }
165
+ pageSize = { limit }
166
+ onPageChange = { onPageChange }
167
+ currentPage = { page }
168
168
/>
169
169
) }
170
170
</ Margins >
You can’t perform that action at this time.
0 commit comments