-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdev.js
66 lines (60 loc) · 1.84 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
import { PropTypes } from 'react'
import { render } from 'react-dom'
import Track from './src/track/index'
import { mySlide, track, slider } from './dev-style.css'
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} startAt={4} infinite>{
(_next, _prev) => {
onNext = _next
onPrev = _prev
return children
}
}</Track>
<button onClick={next}>{'>'}</button>
</div>
)
}
Slider.propTypes = {
children: array
}
render((
<Slider>
<figure className={mySlide}>
<img alt="Fill Murry" src="http://www.fillmurray.com/400/300" />
<figcaption>Slide Index 0</figcaption>
</figure>
<figure className={mySlide}>
<img alt="Fill Murry" src="http://www.fillmurray.com/400/400" />
<figcaption>Slide Index 1</figcaption>
</figure>
<div className={mySlide}>
<figure>
<img alt="Fill Murry" src="http://www.fillmurray.com/300/200" />
</figure>
<figure>
<img alt="Fill Murry" src="http://www.fillmurray.com/300/200" />
<figcaption>Slide Index 2</figcaption>
</figure>
</div>
<figure className={mySlide}>
<img alt="Fill Murry" src="http://www.fillmurray.com/400/200" />
<figcaption>Slide Index 3</figcaption>
</figure>
<figure className={mySlide}>
<img alt="Fill Murry" src="http://www.fillmurray.com/200/400" />
<figcaption>Slide Index 4</figcaption>
</figure>
<figure className={mySlide}>
<img alt="Fill Murry" src="http://www.fillmurray.com/400/400" />
<figcaption>Slide Index 5</figcaption>
</figure>
</Slider>
), document.querySelector('main'))