-
-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathColorPicker.js
55 lines (50 loc) · 1.42 KB
/
ColorPicker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import ColorPickerWidget from '../widgets/ColorPicker';
import Field from './Field';
import PropTypes from 'prop-types';
import React, {Component} from 'react';
import {connectToContainer} from 'lib';
export class UnconnectedColorPicker extends Component {
constructor(props, context) {
super(props, context);
this.state = {
empty: !this.props.fullValue && this.props.handleEmpty,
};
}
render() {
if (this.state.empty) {
return (
<Field {...this.props}>
<div className="js-test-info">
This color is computed from other parts of the figure but you can{' '}
<a
onClick={() => {
this.setState({empty: false});
this.props.updatePlot(this.props.defaultColor);
}}
>
override it
</a>
.
</div>
</Field>
);
}
return (
<Field {...this.props} noDefaultIndicator={this.props.noDefaultIndicator}>
<ColorPickerWidget
selectedColor={this.props.fullValue}
onColorChange={this.props.updatePlot}
/>
</Field>
);
}
}
UnconnectedColorPicker.propTypes = {
fullValue: PropTypes.any,
updatePlot: PropTypes.func,
handleEmpty: PropTypes.bool,
defaultColor: PropTypes.string,
noDefaultIndicator: PropTypes.bool,
...Field.propTypes,
};
export default connectToContainer(UnconnectedColorPicker);