Better open close in color picker

This commit is contained in:
Lukas Martinelli 2016-12-17 22:28:24 +01:00
parent 073dcfe387
commit be664bbd24

View file

@ -18,20 +18,43 @@ static propTypes = {
doc: React.PropTypes.string,
}
constructor(props) {
super(props)
this.state = {
pickerOpened: false
}
}
togglePicker() {
this.setState({ pickerOpened: !this.state.pickerOpened })
}
render() {
return <div style={{...inputStyle.property, position: 'relative'}}>
<div style={{
const picker = <div style={{
position: 'absolute',
left: 200
left: 287
}}>
<ChromePicker
color={getColor(this.props.value)}
onChange={c => this.props.onChange(formatColor(c))}
/>
<div
onClick={this.togglePicker.bind(this)}
style={{
zIndex: -1,
position: 'fixed',
top: '0px',
right: '0px',
bottom: '0px',
left: '0px',
}} />
</div>
return <div style={{...inputStyle.property, position: 'relative'}}>
{this.state.pickerOpened && picker}
<label style={inputStyle.label}>{this.props.name}</label>
<input
onClick={this.togglePicker.bind(this)}
style={inputStyle.input}
name={this.props.name}
placeholder={this.props.default}