diff --git a/src/fields/boolean.jsx b/src/fields/boolean.jsx new file mode 100644 index 0000000..d149410 --- /dev/null +++ b/src/fields/boolean.jsx @@ -0,0 +1,27 @@ +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, + } + + render() { + return
+ + {this.props.onChange(!this.props.value)}} + checked={this.props.value} + > + +
+ } +} + +export default BooleanField diff --git a/src/fields/spec.jsx b/src/fields/spec.jsx index 9cf2146..dac6463 100644 --- a/src/fields/spec.jsx +++ b/src/fields/spec.jsx @@ -5,6 +5,7 @@ import color from 'color' import GlSpec from 'mapbox-gl-style-spec/reference/latest.min.js' import NumberField from './number' import EnumField from './enum' +import BooleanField from './boolean' import ColorField from './color' import StringField from './string' import inputStyle from './input.js' @@ -30,6 +31,7 @@ class ZoomSpecField extends React.Component { React.PropTypes.object, React.PropTypes.string, React.PropTypes.number, + React.PropTypes.bool, ]), } @@ -122,6 +124,14 @@ class SpecField extends React.Component { doc={this.props.fieldSpec.doc} /> ) + case 'boolean': return ( + + ) default: return null } }