/
buttons.js
51 lines (48 loc) · 1.14 KB
/
buttons.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
import React from 'react'
import propTypes from 'prop-types'
const styles = {
wrapper: {
position: 'absolute',
width: '100%',
zIndex: '100',
bottom: '0',
textAlign: 'center'
},
btn: {
width: '30px',
height: '30px',
cursor: 'pointer',
userSelect: 'none',
position: 'absolute',
bottom: '0',
font: '16px/30px sans-serif',
color: 'rgba(255,255,255,0.8)'
},
left: {
left: '0'
},
right: {
right: '0'
}
}
export default function Buttons (props) {
const prevBtnStyle = Object.assign({}, styles.btn, styles.left)
const nextBtnStyle = Object.assign({}, styles.btn, styles.right)
const { index, total, loop, prevHandler, nextHandler } = props
return (
<div style={styles.wrapper}>
{ (loop || index !== 0) && (
<div style={prevBtnStyle} onClick={prevHandler}>◀</div>
)}
{ (loop || index !== total - 1) && (
<div style={nextBtnStyle} onClick={nextHandler}>▶</div>
)}
</div>
)
}
Buttons.propTypes = {
index: propTypes.number.isRequired,
total: propTypes.number.isRequired,
prevHandler: propTypes.func,
nextHandler: propTypes.func
}