mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 15:21:20 +01:00
Better open close in color picker
This commit is contained in:
parent
073dcfe387
commit
be664bbd24
1 changed files with 35 additions and 12 deletions
|
@ -10,7 +10,7 @@ function formatColor(color) {
|
||||||
|
|
||||||
/*** Number fields with support for min, max and units and documentation*/
|
/*** Number fields with support for min, max and units and documentation*/
|
||||||
class ColorField extends React.Component {
|
class ColorField extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
onChange: React.PropTypes.func.isRequired,
|
onChange: React.PropTypes.func.isRequired,
|
||||||
name: React.PropTypes.string.isRequired,
|
name: React.PropTypes.string.isRequired,
|
||||||
value: React.PropTypes.string,
|
value: React.PropTypes.string,
|
||||||
|
@ -18,20 +18,43 @@ static propTypes = {
|
||||||
doc: React.PropTypes.string,
|
doc: React.PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
constructor(props) {
|
||||||
return <div style={{...inputStyle.property, position: 'relative'}}>
|
super(props)
|
||||||
<div style={{
|
this.state = {
|
||||||
position: 'absolute',
|
pickerOpened: false
|
||||||
left: 200
|
}
|
||||||
}}>
|
}
|
||||||
<ChromePicker
|
|
||||||
color={getColor(this.props.value)}
|
|
||||||
onChange={c => this.props.onChange(formatColor(c))}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
togglePicker() {
|
||||||
|
this.setState({ pickerOpened: !this.state.pickerOpened })
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const picker = <div style={{
|
||||||
|
position: 'absolute',
|
||||||
|
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>
|
<label style={inputStyle.label}>{this.props.name}</label>
|
||||||
<input
|
<input
|
||||||
|
onClick={this.togglePicker.bind(this)}
|
||||||
style={inputStyle.input}
|
style={inputStyle.input}
|
||||||
name={this.props.name}
|
name={this.props.name}
|
||||||
placeholder={this.props.default}
|
placeholder={this.props.default}
|
||||||
|
|
Loading…
Reference in a new issue