| | |
| | | import PropTypes from 'prop-types' |
| | | // import { is, fromJS } from 'immutable' |
| | | import { SketchPicker } from 'react-color' |
| | | import {Popover } from 'antd' |
| | | import { Popover } from 'antd' |
| | | |
| | | import './index.scss' |
| | | |
| | | class ColorSketch extends Component { |
| | | static propTpyes = { |
| | | color: PropTypes.any, |
| | | changeColor: PropTypes.func |
| | | value: PropTypes.any, |
| | | onChange: PropTypes.func |
| | | } |
| | | state = { |
| | | color: this.props.color, |
| | | color: this.props.value, |
| | | } |
| | | |
| | | handleChange = (color) => { |
| | | this.setState({ color: color.rgb }) |
| | | this.props.changeColor(`rgba(${ color.rgb.r }, ${ color.rgb.g }, ${ color.rgb.b }, ${ color.rgb.a })`) |
| | | this.props.onChange(`rgba(${ color.rgb.r }, ${ color.rgb.g }, ${ color.rgb.b }, ${ color.rgb.a })`) |
| | | } |
| | | |
| | | render() { |
| | |
| | | } |
| | | |
| | | return ( |
| | | <Popover content={ |
| | | <SketchPicker color={ this.state.color } onChange={ this.handleChange } /> |
| | | } overlayClassName="color-sketch-popover" placement="bottomRight" title="" trigger="click"> |
| | | <div className="color-sketch-block"> |
| | | <div className="color-sketch-block"> |
| | | <Popover content={ |
| | | <SketchPicker color={ this.state.color } onChange={ this.handleChange } /> |
| | | } overlayClassName="color-sketch-popover" placement="bottomRight" title="" trigger="click"> |
| | | <div className="color-sketch-block-inner" style={ {background: _color} }></div> |
| | | </div> |
| | | </Popover> |
| | | </Popover> |
| | | <div className="color-sketch-value">{_color}</div> |
| | | </div> |
| | | ) |
| | | } |
| | | } |