mirror of
https://github.com/dsoaress/link-free.git
synced 2026-08-18 07:26:03 +01:00
refactor: with styled-components
This commit is contained in:
35
src/components/Dash/ColorPicker/index.tsx
Normal file
35
src/components/Dash/ColorPicker/index.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import { BlockPicker } from 'react-color'
|
||||
|
||||
import { useData } from '../../../hooks/useData'
|
||||
import { colors } from '../../../styles/colors'
|
||||
|
||||
type ColorPickerProps = {
|
||||
prop: 'texts' | 'socialLinks' | 'background' | 'buttonLinks'
|
||||
}
|
||||
|
||||
export function ColorPicker({ prop }: ColorPickerProps) {
|
||||
const { data, setData } = useData()
|
||||
|
||||
const handleChange = (color: string) => {
|
||||
setData({
|
||||
...data,
|
||||
settings: {
|
||||
...data.settings,
|
||||
colors: {
|
||||
...data.settings.colors,
|
||||
[prop]: color
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<BlockPicker
|
||||
color={data.settings.colors[prop]}
|
||||
colors={colors}
|
||||
triangle="hide"
|
||||
width="100%"
|
||||
onChangeComplete={color => handleChange(color.hex)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user