-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathNavigation.js
91 lines (82 loc) · 2.01 KB
/
Navigation.js
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
import React from 'react'
import PropTypes from 'prop-types'
export const CustomPrevButton = (props) => {
const { page, handlePrevClick } = props
if (page === 1) return <div />
return (
<h3
style={{
cursor: 'pointer',
display: 'inline-block',
marginRight: 24,
marginTop: 0,
}}
onClick={handlePrevClick}>
Previous page
</h3>
)
}
CustomPrevButton.propTypes = {
page: PropTypes.number.isRequired,
pages: PropTypes.number.isRequired,
handlePrevClick: PropTypes.func.isRequired,
}
export const CustomNextButton = (props) => {
const { page, pages, handleNextClick } = props
if (page === pages) return <div />
return (
<h3
style={{
cursor: 'pointer',
display: 'inline-block',
marginLeft: 24,
marginTop: 0,
}}
onClick={handleNextClick}>
Next page
</h3>
)
}
CustomNextButton.propTypes = {
page: PropTypes.number.isRequired,
pages: PropTypes.number.isRequired,
handleNextClick: PropTypes.func.isRequired,
}
export const CustomPages = (props) => {
const { page, pages } = props
return (
<h3 style={{ display: 'inline-block', marginTop: 0 }}>
Page {page} from {pages}
</h3>
)
}
CustomPages.propTypes = {
page: PropTypes.number.isRequired,
pages: PropTypes.number.isRequired,
}
const CustomNavigation = (props) => {
const { page, pages } = props
const { handlePrevClick, handleNextClick } = props
return (
<div className='customWrapper'>
<CustomPrevButton
page={page}
pages={pages}
handlePrevClick={handlePrevClick}
/>
<CustomPages page={page} pages={pages} />
<CustomNextButton
page={page}
pages={pages}
handleNextClick={handleNextClick}
/>
</div>
)
}
CustomNavigation.propTypes = {
page: PropTypes.number.isRequired,
pages: PropTypes.number.isRequired,
handlePrevClick: PropTypes.func.isRequired,
handleNextClick: PropTypes.func.isRequired,
}
export default CustomNavigation