-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdev.js
77 lines (70 loc) · 1.53 KB
/
dev.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
import { PropTypes } from 'react'
import { render } from 'react-dom'
import Track from './src/track/index'
const { array } = PropTypes
const Slider = ({ children }) => {
let onNext
let onPrev
const next = () => onNext()
const prev = () => onPrev()
return (
<div className="slider">
<button onClick={prev}>{'<'}</button>
<Track
visibleSlides={3}
className="track"
slideClass="slideClassName"
onSlideClick={() => { console.log('You clicked on a slide!') }}
>{
(_next, _prev) => {
onNext = _next
onPrev = _prev
return children
}
}</Track>
<button onClick={next}>{'>'}</button>
</div>
)
}
Slider.propTypes = {
children: array
}
const slides = [{
src: 'https://placezombie.com',
height: 300,
width: 300
}, {
src: 'https://placezombie.com',
height: 300,
width: 300
}, {
src: 'https://placezombie.com',
height: 300,
width: 300
}, {
src: 'https://placezombie.com',
height: 300,
width: 300
}, {
src: 'https://placezombie.com',
height: 300,
width: 300
}, {
src: 'https://placezombie.com',
height: 300,
width: 300
}, {
src: 'https://placezombie.com',
height: 300,
width: 300
}]
render((
<Slider>
{slides.map(({ src, height, width }, i) => (
<figure className="mySlide" key={`${src}-${i}`}>
<img alt="Place Zombie" src={`${src}/${width}x${height}?${i}`} />
<figcaption>Slide Index {i}</figcaption>
</figure>
))}
</Slider>
), document.querySelector('main'))