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"; |
import { SketchPicker } from "react-color"; |
||||||
|
|
||||||
const Picker = ({ theme, item, setTheme }) => { |
const Picker = ({ theme, item, setTheme, position }) => { |
||||||
const [color, setColor] = useState(theme[item]); |
const [color, setColor] = useState(theme[item]); |
||||||
|
useEffect(() => { |
||||||
|
setColor(theme[item]); |
||||||
|
}, [theme,item]); |
||||||
|
|
||||||
|
console.log({ position }); |
||||||
return ( |
return ( |
||||||
<SketchPicker |
<div className={`absolute`} style={position}> |
||||||
className="absolute bottom-0 left-1/2" |
<SketchPicker |
||||||
color={color} |
color={color} |
||||||
onChange={(updatedColor) => { |
onChange={(updatedColor) => { |
||||||
setColor(updatedColor.hex); |
setColor(updatedColor.hex); |
||||||
setTheme({ ...theme, [item]: updatedColor.hex }); |
setTheme({ ...theme, [item]: updatedColor.hex }); |
||||||
}} |
}} |
||||||
/> |
/> |
||||||
|
</div> |
||||||
); |
); |
||||||
}; |
}; |
||||||
export default Picker; |
export default Picker; |
||||||
|
Loading…
Reference in new issue