-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo.jsx
41 lines (40 loc) · 1.47 KB
/
demo.jsx
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
import React from 'react'
import Selector from './index'
export default class SelectorDemo extends React.Component {
constructor(props) {
super(props)
this.state = {
current1: 1,
current2: 1
}
}
render() {
const opts1 = [
{ img: '/img/pic1.jpg', label: 'First Item', value: 1 },
{ img: '/img/pic2.jpg', label: 'Second Item', value: 2 },
{ img: '/img/pic3.jpg', label: 'Third Item', value: 3 }
]
const onSelect1 = opt => { this.setState({ current1: opt.value }); console.log('selected', opt) }
const opts2 = [
{ el: <div><strong>First</strong> El</div>, value: 1 },
{ el: <div><strong>Second</strong> El</div>, value: 2 },
{ el: <div><strong>Third</strong> El</div>, value: 3 }
]
const onSelect2 = opt => { this.setState({ current2: opt.value }); console.log('selected', opt) }
return <div>
<h1>patchkit-selector</h1>
<section className="selector-label-img">
<header><Selector options=[{ img:, label:, value: }, ...]></header>
<div className="content">
<Selector options={opts1} value={this.state.current1} onSelect={onSelect1} />
</div>
</section>
<section className="selector-el">
<header><Selector options=[{ el:, value: }, ...]></header>
<div className="content">
<Selector options={opts2} value={this.state.current2} onSelect={onSelect2} />
</div>
</section>
</div>
}
}