king
2020-07-03 ee2f7a97abc91d3dbafe3b6612719a4aa3e5bdc8
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
import React, {Component} from 'react'
import PropTypes from 'prop-types'
// import { is, fromJS } from 'immutable'
import { SketchPicker } from 'react-color'
import {Popover } from 'antd'
 
import './index.scss'
 
class ColorSketch extends Component {
  static propTpyes = {
    card: PropTypes.object,
    onDoubleClick: PropTypes.func
  }
  state = {
    visible: false,
    color: '#f8e71c',
  };
 
  handleClick = () => {
    this.setState({ visible: !this.state.visible })
  };
 
  handleClose = () => {
    this.setState({ visible: false })
  };
 
  handleChange = (color) => {
    this.setState({ color: color.rgb })
  };
 
  render() {
    const { color } = this.state
    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" onClick={ this.handleClick }>
          <div className="color-sketch-block-inner" style={ {background: `rgba(${ color.r }, ${ color.g }, ${ color.b }, ${ color.a })`} }></div>
        </div>
      </Popover>
    )
  }
}
 
export default ColorSketch