diff --git a/src/fields/color.jsx b/src/fields/color.jsx index caae14f..8cd477f 100644 --- a/src/fields/color.jsx +++ b/src/fields/color.jsx @@ -10,7 +10,7 @@ function formatColor(color) { /*** Number fields with support for min, max and units and documentation*/ class ColorField extends React.Component { -static propTypes = { + static propTypes = { onChange: React.PropTypes.func.isRequired, name: React.PropTypes.string.isRequired, value: React.PropTypes.string, @@ -18,20 +18,43 @@ static propTypes = { doc: React.PropTypes.string, } - render() { - return
-
- this.props.onChange(formatColor(c))} - /> -
+ constructor(props) { + super(props) + this.state = { + pickerOpened: false + } + } + togglePicker() { + this.setState({ pickerOpened: !this.state.pickerOpened }) + } + + render() { + const picker =
+ this.props.onChange(formatColor(c))} + /> +
+
+ + return
+ {this.state.pickerOpened && picker}