maputnik/src/fields/boolean.jsx

32 lines
782 B
React
Raw Normal View History

2016-12-18 20:08:20 +01:00
import React from 'react'
import inputStyle from './input.js'
class BooleanField extends React.Component {
static propTypes = {
onChange: React.PropTypes.func.isRequired,
name: React.PropTypes.string.isRequired,
value: React.PropTypes.bool,
doc: React.PropTypes.string,
2016-12-19 16:21:22 +01:00
style: React.PropTypes.object,
2016-12-18 20:08:20 +01:00
}
render() {
return <div style={inputStyle.property}>
<label style={inputStyle.label}>{this.props.name}</label>
<input
type="checkbox"
2016-12-19 16:21:22 +01:00
style={{
...inputStyle.checkbox,
...this.props.style
}}
2016-12-18 20:08:20 +01:00
value={this.props.value}
onChange={e => {this.props.onChange(!this.props.value)}}
checked={this.props.value}
>
</input>
</div>
}
}
export default BooleanField