/
PaginatorCodePage.tsx
157 lines (154 loc) · 4.34 KB
/
PaginatorCodePage.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import Code from "@/common/Code";
import DocFooter from "@/common/DocFooter";
import Example from "@/common/example/Example";
import QuickNavContainer from "@/common/QuickNavContainer";
import QuickNavContainerLayout from "@/common/QuickNavContainerLayout";
import {
DxcFlex,
DxcTable,
DxcParagraph,
} from "@dxc-technology/halstack-react";
import itemsPerPage from "./examples/itemsPerPage";
import TableCode from "@/common/TableCode";
const sections = [
{
title: "Props",
content: (
<DxcTable>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>currentPage</td>
<td>
<TableCode>number</TableCode>
</td>
<td>Number of the current selected page.</td>
<td>
<TableCode>1</TableCode>
</td>
</tr>
<tr>
<td>itemsPerPage</td>
<td>
<TableCode>number</TableCode>
</td>
<td>Number of items per page.</td>
<td>
<TableCode>5</TableCode>
</td>
</tr>
<tr>
<td>itemsPerPageOptions</td>
<td>
<TableCode>number[]</TableCode>
</td>
<td>
An array of numbers representing the items per page options. If
undefined, the select with items per page options will not be
displayed.
</td>
<td>-</td>
</tr>
<tr>
<td>itemsPerPageFunction</td>
<td>
<TableCode>{"(itemsPerPage: number) => void"}</TableCode>
</td>
<td>
This function will be called when the user selects an item per
page option. The number of items per page will be passed as a
parameter to this function.
</td>
<td>-</td>
</tr>
<tr>
<td>totalItems</td>
<td>
<TableCode>number</TableCode>
</td>
<td>Total number of items in the pages.</td>
<td>
<TableCode>1</TableCode>
</td>
</tr>
<tr>
<td>showGoToPage</td>
<td>
<TableCode>boolean</TableCode>
</td>
<td>
If true, a select will be displayed with the page numbers to move
through them
</td>
<td>
<TableCode>false</TableCode>
</td>
</tr>
<tr>
<td>onPageChange</td>
<td>
<TableCode>{"(page: number) => void"}</TableCode>
</td>
<td>
This function will be called when the user clicks on any of the
button to change pages. The page number will be passed as a
parameter to this function.
</td>
<td>-</td>
</tr>
<tr>
<td>tabIndex</td>
<td>
<TableCode>number</TableCode>
</td>
<td>
Value of the <Code>tabindex</Code> attribute.
</td>
<td>
<TableCode>0</TableCode>
</td>
</tr>
</tbody>
</DxcTable>
),
},
{
title: "Examples",
subSections: [
{
title: "Items per page",
content: (
<>
<DxcParagraph>
This is an example of how to display 'Items per Page' select and
how to handle it through the <Code>itemsPerPageFunction</Code>{" "}
function.
</DxcParagraph>
<Example example={itemsPerPage} defaultIsVisible />
</>
),
},
],
},
];
const PaginatorCodePage = () => {
return (
<DxcFlex direction="column" gap="4rem">
<QuickNavContainerLayout>
<QuickNavContainer
sections={sections}
startHeadingLevel={2}
></QuickNavContainer>
</QuickNavContainerLayout>
<DocFooter githubLink="https://github.com/dxc-technology/halstack-react/blob/master/website/screens/components/paginator/code/PaginatorCodePage.tsx" />
</DxcFlex>
);
};
export default PaginatorCodePage;