maputnik/src/components/fields/BooleanField.jsx

29 lines
648 B
React
Raw Normal View History

2016-12-18 20:08:20 +01:00
import React from 'react'
2016-12-20 11:44:22 +01:00
import input from '../../config/input.js'
2016-12-18 20:08:20 +01:00
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() {
2016-12-19 16:30:48 +01:00
return <input
type="checkbox"
style={{
2016-12-20 11:44:22 +01:00
...input.checkbox,
2016-12-19 16:30:48 +01:00
...this.props.style
}}
value={this.props.value}
onChange={e => {this.props.onChange(!this.props.value)}}
checked={this.props.value}
>
</input>
2016-12-18 20:08:20 +01:00
}
}
export default BooleanField