parent
1c2e015430
commit
471a9d13d0
5 changed files with 51 additions and 27 deletions
@ -1,17 +1,23 @@ |
||||
import { useState } from "react"; |
||||
import { useState, useEffect } from "react"; |
||||
import { SketchPicker } from "react-color"; |
||||
|
||||
const Picker = ({ theme, item, setTheme }) => { |
||||
const Picker = ({ theme, item, setTheme, position }) => { |
||||
const [color, setColor] = useState(theme[item]); |
||||
useEffect(() => { |
||||
setColor(theme[item]); |
||||
}, [theme,item]); |
||||
|
||||
console.log({ position }); |
||||
return ( |
||||
<div className={`absolute`} style={position}> |
||||
<SketchPicker |
||||
className="absolute bottom-0 left-1/2" |
||||
color={color} |
||||
onChange={(updatedColor) => { |
||||
setColor(updatedColor.hex); |
||||
setTheme({ ...theme, [item]: updatedColor.hex }); |
||||
}} |
||||
/> |
||||
</div> |
||||
); |
||||
}; |
||||
export default Picker; |
||||
|
Loading…
Reference in new issue