@@ -5,7 +5,7 @@ import InputNumber from 'react-input-number';
55import {
66 rgb2hsv ,
77 hsv2hex ,
8- rgba2hex ,
8+ rgb2hex ,
99 hex2rgb ,
1010 rgba ,
1111 hsv2rgb
@@ -18,25 +18,24 @@ const ColorPicker = ({ color, onChange }) => {
1818
1919 function changeColor ( color ) {
2020 if ( onChange ) {
21- onChange ( color ) ;
21+ onChange ( { ... color , rgba : rgba ( color . r , color . g , color . b , color . a ) } ) ;
2222 }
2323 }
2424
2525 function changeHSV ( h , s , v ) {
2626 const { r, g, b } = hsv2rgb ( h , s , v ) ;
27- const hex = rgba2hex ( r , g , b , a ) ;
27+ const hex = rgb2hex ( r , g , b ) ;
2828 changeColor ( { ...color , h, s, v, r, g, b, hex } ) ;
2929 }
3030
3131 function changeRGB ( r , g , b ) {
32- const hex = rgba2hex ( r , g , b , a ) ;
32+ const hex = rgb2hex ( r , g , b ) ;
3333 const { h, s, v } = rgb2hsv ( r , g , b ) ;
3434 changeColor ( { ...color , r, g, b, h, s, v, hex } ) ;
3535 }
3636
3737 function changeAlpha ( a ) {
38- const hex = rgba2hex ( r , g , b , a ) ;
39- changeColor ( { ...color , a, hex } ) ;
38+ changeColor ( { ...color , a } ) ;
4039 }
4140
4241 function changeHex ( hex ) {
@@ -190,7 +189,12 @@ const ColorPicker = ({ color, onChange }) => {
190189 </ div >
191190
192191 < div css = { styles . input } >
193- < InputNumber value = { a } onChange = { a => changeAlpha ( a ) } />
192+ < InputNumber
193+ min = { 0 }
194+ max = { 100 }
195+ value = { a }
196+ onChange = { a => changeAlpha ( a ) }
197+ />
194198 < div > A</ div >
195199 </ div >
196200 </ div >
@@ -199,7 +203,7 @@ const ColorPicker = ({ color, onChange }) => {
199203} ;
200204
201205ColorPicker . defaultProps = {
202- initialHexColor : '#5e72e4'
206+ initialValue : '#5e72e4'
203207} ;
204208
205209const styles = {
0 commit comments