-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PBNTR-736] Adding React Advanced Table Pagination (#3962)
**What does this PR do?** Adding React Advanced Table pagination **Screenshots:** ![image](https://github.com/user-attachments/assets/48ef6aaa-f3d7-4e6b-8720-47e876e07830) #### Checklist: - [x] **LABELS** Add a label: `enhancement`, `bug`, `improvement`, `new kit`, `deprecated`, or `breaking`. See [Changelog & Labels](https://github.com/powerhome/playbook/wiki/Changelog-&-Labels) for details. - [x] **DEPLOY** I have added the `milano` label to show I'm ready for a review. - [ ] **TESTS** I have added test coverage to my code. --------- Co-authored-by: Nida Ghuman <[email protected]>
- Loading branch information
1 parent
4b37c45
commit bcc10b3
Showing
9 changed files
with
5,780 additions
and
19 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
50 changes: 50 additions & 0 deletions
50
playbook/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.jsx
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from "react" | ||
import { AdvancedTable } from "playbook-ui" | ||
import PAGINATION_MOCK_DATA from "./advanced_table_pagination_mock_data.json" | ||
|
||
const AdvancedTablePagination = (props) => { | ||
const columnDefinitions = [ | ||
{ | ||
accessor: "year", | ||
label: "Year", | ||
cellAccessors: ["quarter", "month", "day"], | ||
}, | ||
{ | ||
accessor: "newEnrollments", | ||
label: "New Enrollments", | ||
}, | ||
{ | ||
accessor: "scheduledMeetings", | ||
label: "Scheduled Meetings", | ||
}, | ||
{ | ||
accessor: "attendanceRate", | ||
label: "Attendance Rate", | ||
}, | ||
{ | ||
accessor: "completedClasses", | ||
label: "Completed Classes", | ||
}, | ||
{ | ||
accessor: "classCompletionRate", | ||
label: "Class Completion Rate", | ||
}, | ||
{ | ||
accessor: "graduatedStudents", | ||
label: "Graduated Students", | ||
}, | ||
] | ||
|
||
return ( | ||
<> | ||
<AdvancedTable | ||
columnDefinitions={columnDefinitions} | ||
pagination | ||
tableData={PAGINATION_MOCK_DATA} | ||
{...props} | ||
/> | ||
</> | ||
) | ||
} | ||
|
||
export default AdvancedTablePagination |
1 change: 1 addition & 0 deletions
1
playbook/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.md
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
`pagination` is an optional prop that can be used to add pagination to the AdvancedTable. If present, it will add pagination with default values for pageSize, etc. To customize pagination, you can also use `paginationProps` shown in the next example. |
57 changes: 57 additions & 0 deletions
57
...ook/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.jsx
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from "react" | ||
import { AdvancedTable } from "playbook-ui" | ||
import PAGINATION_MOCK_DATA from "./advanced_table_pagination_mock_data.json" | ||
|
||
const AdvancedTablePaginationWithProps = (props) => { | ||
const columnDefinitions = [ | ||
{ | ||
accessor: "year", | ||
label: "Year", | ||
cellAccessors: ["quarter", "month", "day"], | ||
}, | ||
{ | ||
accessor: "newEnrollments", | ||
label: "New Enrollments", | ||
}, | ||
{ | ||
accessor: "scheduledMeetings", | ||
label: "Scheduled Meetings", | ||
}, | ||
{ | ||
accessor: "attendanceRate", | ||
label: "Attendance Rate", | ||
}, | ||
{ | ||
accessor: "completedClasses", | ||
label: "Completed Classes", | ||
}, | ||
{ | ||
accessor: "classCompletionRate", | ||
label: "Class Completion Rate", | ||
}, | ||
{ | ||
accessor: "graduatedStudents", | ||
label: "Graduated Students", | ||
}, | ||
] | ||
|
||
const paginationProps = { | ||
pageIndex: 1, | ||
pageSize: 10, | ||
range: 2 | ||
} | ||
|
||
return ( | ||
<> | ||
<AdvancedTable | ||
columnDefinitions={columnDefinitions} | ||
pagination | ||
paginationProps={paginationProps} | ||
tableData={PAGINATION_MOCK_DATA} | ||
{...props} | ||
/> | ||
</> | ||
) | ||
} | ||
|
||
export default AdvancedTablePaginationWithProps |
5 changes: 5 additions & 0 deletions
5
...b_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.md
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
`paginationProps` is an optional prop that can be used to further customize pagination for the AdvancedTable. This prop is an object with 2 optional items: | ||
|
||
- `pageIndex`: An optional prop to set which page is set to open on initial load. Default is '0' | ||
- `pageSize`: An optional prop to set total number of rows for each page before the Table paginates. Default is '20' | ||
- `range`: The range prop determines how many pages to display in the Pagination component. Regardless of this value, the first two and last two pages are always visible to facilitate navigation to the beginning and end of the pagination. If these always-visible pages fall within the specified range, they are included in the display. If they fall outside the range, the pagination will show additional pages up to the number defined by the range prop. See [here for more details](https://playbook.powerapp.cloud/kits/pagination/react#default). Default is set to '5' |
Oops, something went wrong.