react-toolbox/spec/components/switch.jsx

42 lines
1.0 KiB
React
Raw Normal View History

import React from 'react';
2015-09-21 11:01:52 +03:00
import Switch from '../../components/switch';
2015-10-22 02:31:17 +03:00
class SwitchTest extends React.Component {
2015-11-12 07:52:05 +03:00
state = {
switch: [true, false, false]
};
handleChange = (index, value) => {
2015-11-12 07:52:05 +03:00
const state = this.state.switch;
state[index] = value;
2015-11-12 07:52:05 +03:00
this.setState({switch: state});
2015-10-22 02:31:17 +03:00
};
2015-09-21 11:01:52 +03:00
render () {
return (
<section>
2015-10-07 23:24:02 +03:00
<h5>Switches</h5>
<p style={{marginBottom: '10px'}}>This is more beautiful than the old fashion checkboxes...</p>
2015-11-12 07:52:05 +03:00
<Switch
checked={this.state.switch[0]}
label="Push notifications"
onChange={this.handleChange.bind(this, 0)}
/>
<Switch
checked={this.state.switch[1]}
label="Mail notifications"
onChange={this.handleChange.bind(this, 1)}
/>
<Switch
checked={this.state.switch[2]}
disabled
label="Nothing, thanks"
onChange={this.handleChange.bind(this, 2)}
/>
2015-09-21 11:01:52 +03:00
</section>
);
}
2015-10-21 13:25:07 +03:00
}
2015-10-22 02:31:17 +03:00
export default SwitchTest;