| | |
| | | } |
| | | state = { |
| | | color: '', |
| | | colors: [], |
| | | allowClear: false |
| | | } |
| | | |
| | |
| | | } else if (value) { |
| | | initVal = value |
| | | } |
| | | |
| | | let _colors = sessionStorage.getItem('app_colors') || [] |
| | | try { |
| | | _colors = JSON.parse(_colors) |
| | | } catch { |
| | | _colors = [] |
| | | } |
| | | |
| | | this.setState({color: initVal, allowClear: allowClear === true}) |
| | | let colors = presetColors.map((item, i) => { |
| | | if (_colors[i] && _colors[i].linkurl && !presetColors.includes(_colors[i].linkurl)) { |
| | | return _colors[i].linkurl |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | this.setState({color: initVal, allowClear: allowClear === true, colors}) |
| | | } |
| | | |
| | | handleChange = (color) => { |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { color, allowClear } = this.state |
| | | const { color, allowClear, colors } = this.state |
| | | return ( |
| | | <div className="color-sketch-block"> |
| | | <Popover content={ |
| | | <SketchPicker color={ color } presetColors={presetColors} onChange={ this.handleChange } /> |
| | | <SketchPicker color={ color } presetColors={colors} onChange={ this.handleChange } /> |
| | | } overlayClassName="color-sketch-popover" placement="bottomRight" title="" trigger="click"> |
| | | <div className="color-sketch-block-box"> |
| | | <div className="color-sketch-block-inner" style={ {background: color} }></div> |