Colt / react-colors

Clone of Flat UI Colors, made for my Modern React Bootcamp Course
205 stars 232 forks source link

Color Picker rgba problem #4

Closed farshidinanloo closed 4 years ago

farshidinanloo commented 5 years ago

we can't use opacity for rgba in color picker when it changes it moves back to the first place 4

farshidinanloo commented 5 years ago

I find out the solution :

in ColorPickerForm replace this code

updateCurrentColor(newColor) { this.setState({ currentColor: newColor.hex }); }

with this

updateCurrentColor(newColor) {
     const r = newColor.rgb.r;
     const g = newColor.rgb.g;
     const b = newColor.rgb.b;
     const a = newColor.rgb.a;
     const rgbaColor = `rgba(${r},${g},${b},${a})`;

    this.setState({ currentColor: rgbaColor });
  }