1 import React from 'react';
4 class ToggleInput extends React.Component {
7 label: React.PropTypes.node,
8 value: React.PropTypes.bool,
9 onChange: React.PropTypes.func,
10 disabled: React.PropTypes.bool
13 static defaultProps = {
19 value: this.props.value
23 return this.state.value ? 'on' : 'off';
27 let {label, disabled} = this.props;
28 let checked = this.status() === 'on';
30 <div className='toggle-input-wrapper form-group' onClick={!disabled && this.click}>
31 <div className='toggle-input-label'>{label}</div>
32 <div className='toggle-switch'>
33 <input className='toggle toggle-round-flat' type='checkbox' checked={checked} readOnly/>
41 let value = !this.state.value;
42 this.setState({value});
44 let onChange = this.props.onChange;
51 return this.state.value;