1
1
import * as React from "react" ;
2
2
import bem from "../../utils/bem" ;
3
- import Button , { ButtonOptions } from "../Button/Button" ;
4
- import Label from "../Label/Label" ;
5
- import Select from "../Select/Select" ;
6
- import { ButtonIconPositions , ButtonTypes } from "../Button/ButtonTypes" ;
7
- import { IconRotationTypes } from "../Icons/IconTypes" ;
8
3
export interface PaginationProps {
4
+ /** BlockName for use with BEM. See how to work with blockNames and BEM here: http://getbem.com/introduction/ */
9
5
blockName ?: string ;
6
+ /** Additional className for use with BEM. See how to work with blockNames and BEM here: http://getbem.com/introduction/ */
10
7
className ?: string ;
11
- currentValue : string ;
8
+ /** Modifiers array for use with BEM. See how to work with modifiers and BEM here: http://getbem.com/introduction/ */
12
9
modifiers ?: string [ ] ;
13
- nextPageHandler : ( event : React . MouseEvent ) => void ;
14
- onSelectBlur : ( event : React . MouseEvent ) => void ;
15
- onSelectChange : ( event : React . MouseEvent ) => void ;
16
- paginationDropdownOptions : string [ ] ;
17
- previousPageHandler : ( event : React . MouseEvent ) => void ;
10
+ /** Right hand element that is the next handler, typically a button */
11
+ nextPage ?: React . ReactNode ;
12
+ /** Left hand element that is the previous handler, typically a button */
13
+ previousPage ?: React . ReactNode ;
18
14
}
19
15
20
- export default function Pagination ( props : PaginationProps ) {
16
+ export default function Pagination (
17
+ props : React . PropsWithChildren < PaginationProps >
18
+ ) {
21
19
const {
22
20
blockName,
21
+ children,
23
22
className,
24
- currentValue,
25
23
modifiers,
26
- nextPageHandler,
27
- onSelectBlur,
28
- onSelectChange,
29
- paginationDropdownOptions,
30
- previousPageHandler,
24
+ nextPage,
25
+ previousPage,
31
26
} = props ;
32
27
33
28
const pagination__base_class = "pagination" ;
34
- let buttonPrevOpts : ButtonOptions = {
35
- id : "pagination-previous" ,
36
- onClick : previousPageHandler ,
37
- content : < > Previous</ > ,
38
- buttonType : ButtonTypes . Secondary ,
39
- iconPosition : ButtonIconPositions . Left ,
40
- iconRotation : IconRotationTypes . rotate90 ,
41
- iconName : "arrow_xsmall" ,
42
- iconDecorative : true ,
43
- } ;
44
-
45
- let buttonNextOpts : ButtonOptions = {
46
- id : "pagination-next" ,
47
- onClick : nextPageHandler ,
48
- content : < > Next</ > ,
49
- buttonType : ButtonTypes . Secondary ,
50
- iconPosition : ButtonIconPositions . Right ,
51
- iconRotation : IconRotationTypes . rotate270 ,
52
- iconName : "arrow_xsmall" ,
53
- iconDecorative : true ,
54
- } ;
55
-
56
- let dropdownProps = {
57
- dropdownId : "pagination-dropdown" ,
58
- isRequired : false ,
59
- labelId : "pagination-select-label" ,
60
- labelText : "Page" ,
61
- selectedOption : currentValue ,
62
- onChange : onSelectChange ,
63
- onBlur : onSelectBlur ,
64
- } ;
65
29
66
30
return (
67
31
< nav
@@ -70,24 +34,9 @@ export default function Pagination(props: PaginationProps) {
70
34
className ,
71
35
] ) }
72
36
>
73
- < Button onClick = { buttonPrevOpts . onClick } { ...buttonPrevOpts } >
74
- { buttonPrevOpts . content }
75
- </ Button >
76
- < Label htmlFor = "pagination-dropdown" id = { dropdownProps . labelId } >
77
- { dropdownProps . labelText }
78
- </ Label >
79
- < Select
80
- name = "pagination-select"
81
- blockName = { pagination__base_class }
82
- { ...dropdownProps }
83
- >
84
- { paginationDropdownOptions . map ( ( item ) => (
85
- < option aria-selected = { false } > { item } </ option >
86
- ) ) }
87
- </ Select >
88
- < Button onClick = { buttonNextOpts . onClick } { ...buttonNextOpts } >
89
- { buttonNextOpts . content }
90
- </ Button >
37
+ { previousPage }
38
+ { children }
39
+ { nextPage }
91
40
</ nav >
92
41
) ;
93
42
}
0 commit comments