forked from yuristrelets/react-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckbox.jsx
More file actions
58 lines (51 loc) · 1.35 KB
/
checkbox.jsx
File metadata and controls
58 lines (51 loc) · 1.35 KB
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
import React from 'react';
import Checkbox from '../../components/checkbox';
class CheckboxTest extends React.Component {
state = {
checkbox_1: true,
checkbox_2: false,
checkbox_3: true
};
handleChange = (key) => {
const state = this.state;
state[key] = !state[key];
this.setState(state);
};
handleFocus = () => {
console.log('Focused');
};
handleBlur = () => {
console.log('Blur');
};
render () {
return (
<section>
<h5>Checkbox</h5>
<p style={{marginBottom: '10px'}}>Lorem ipsum...</p>
<Checkbox
checked={this.state.checkbox_1}
label="Checked checkbox"
onChange={this.handleChange.bind(this, 'checkbox_1')}
onFocus={this.handleFocus}
onBlur={this.handleBlur}
/>
<Checkbox
checked={this.state.checkbox_2}
label="Not checked biatch"
onChange={this.handleChange.bind(this, 'checkbox_2')}
onFocus={this.handleFocus}
onBlur={this.handleBlur}
/>
<Checkbox
checked={this.state.checkbox_3}
label="Disabled checkbox"
disabled
onChange={this.handleChange.bind(this, 'checkbox_3')}
onFocus={this.handleFocus}
onBlur={this.handleBlur}
/>
</section>
);
}
}
export default CheckboxTest;