|
@@ -14,7 +14,7 @@ export interface Props {
|
|
|
export class ColorPickerPopover extends React.Component<Props, any> {
|
|
export class ColorPickerPopover extends React.Component<Props, any> {
|
|
|
pickerNavElem: any;
|
|
pickerNavElem: any;
|
|
|
|
|
|
|
|
- constructor(props) {
|
|
|
|
|
|
|
+ constructor(props: Props) {
|
|
|
super(props);
|
|
super(props);
|
|
|
this.state = {
|
|
this.state = {
|
|
|
tab: 'palette',
|
|
tab: 'palette',
|
|
@@ -23,60 +23,51 @@ export class ColorPickerPopover extends React.Component<Props, any> {
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- setPickerNavElem(elem) {
|
|
|
|
|
|
|
+ setPickerNavElem(elem: any) {
|
|
|
this.pickerNavElem = $(elem);
|
|
this.pickerNavElem = $(elem);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- setColor(color) {
|
|
|
|
|
|
|
+ setColor(color: string) {
|
|
|
const newColor = tinycolor(color);
|
|
const newColor = tinycolor(color);
|
|
|
if (newColor.isValid()) {
|
|
if (newColor.isValid()) {
|
|
|
- this.setState({
|
|
|
|
|
- color: newColor.toString(),
|
|
|
|
|
- colorString: newColor.toString(),
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ this.setState({ color: newColor.toString(), colorString: newColor.toString() });
|
|
|
this.props.onColorSelect(color);
|
|
this.props.onColorSelect(color);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- sampleColorSelected(color) {
|
|
|
|
|
|
|
+ sampleColorSelected(color: string) {
|
|
|
this.setColor(color);
|
|
this.setColor(color);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- spectrumColorSelected(color) {
|
|
|
|
|
|
|
+ spectrumColorSelected(color: any) {
|
|
|
const rgbColor = color.toRgbString();
|
|
const rgbColor = color.toRgbString();
|
|
|
this.setColor(rgbColor);
|
|
this.setColor(rgbColor);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- onColorStringChange(e) {
|
|
|
|
|
|
|
+ onColorStringChange(e: any) {
|
|
|
const colorString = e.target.value;
|
|
const colorString = e.target.value;
|
|
|
- this.setState({
|
|
|
|
|
- colorString: colorString,
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ this.setState({ colorString: colorString });
|
|
|
|
|
|
|
|
const newColor = tinycolor(colorString);
|
|
const newColor = tinycolor(colorString);
|
|
|
if (newColor.isValid()) {
|
|
if (newColor.isValid()) {
|
|
|
// Update only color state
|
|
// Update only color state
|
|
|
const newColorString = newColor.toString();
|
|
const newColorString = newColor.toString();
|
|
|
- this.setState({
|
|
|
|
|
- color: newColorString,
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ this.setState({ color: newColorString });
|
|
|
this.props.onColorSelect(newColorString);
|
|
this.props.onColorSelect(newColorString);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- onColorStringBlur(e) {
|
|
|
|
|
|
|
+ onColorStringBlur(e: any) {
|
|
|
const colorString = e.target.value;
|
|
const colorString = e.target.value;
|
|
|
this.setColor(colorString);
|
|
this.setColor(colorString);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
componentDidMount() {
|
|
|
this.pickerNavElem.find('li:first').addClass('active');
|
|
this.pickerNavElem.find('li:first').addClass('active');
|
|
|
- this.pickerNavElem.on('show', e => {
|
|
|
|
|
|
|
+ this.pickerNavElem.on('show', (e: any) => {
|
|
|
// use href attr (#name => name)
|
|
// use href attr (#name => name)
|
|
|
const tab = e.target.hash.slice(1);
|
|
const tab = e.target.hash.slice(1);
|
|
|
- this.setState({
|
|
|
|
|
- tab: tab,
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ this.setState({ tab: tab });
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|