From be664bbd24e15d3ce28537f303d26fb6805e8cc7 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Sat, 17 Dec 2016 22:28:24 +0100 Subject: [PATCH] Better open close in color picker --- src/fields/color.jsx | 47 +++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 12 deletions(-) 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}