2021-12-23 09:37:42 +01:00
|
|
|
import { Flex, Text } from '@chakra-ui/react'
|
2022-01-06 09:40:56 +01:00
|
|
|
import { Background, BackgroundType } from 'models'
|
2021-12-23 09:37:42 +01:00
|
|
|
import React from 'react'
|
|
|
|
import { ColorPicker } from '../ColorPicker'
|
|
|
|
|
|
|
|
type BackgroundContentProps = {
|
2022-01-24 15:07:09 +01:00
|
|
|
background?: Background
|
2021-12-23 09:37:42 +01:00
|
|
|
onBackgroundContentChange: (content: string) => void
|
|
|
|
}
|
|
|
|
|
2022-01-24 15:07:09 +01:00
|
|
|
const defaultBackgroundColor = '#ffffff'
|
|
|
|
|
2021-12-23 09:37:42 +01:00
|
|
|
export const BackgroundContent = ({
|
|
|
|
background,
|
|
|
|
onBackgroundContentChange,
|
|
|
|
}: BackgroundContentProps) => {
|
|
|
|
const handleContentChange = (content: string) =>
|
|
|
|
onBackgroundContentChange(content)
|
|
|
|
|
2022-01-24 15:07:09 +01:00
|
|
|
switch (background?.type) {
|
2021-12-23 09:37:42 +01:00
|
|
|
case BackgroundType.COLOR:
|
|
|
|
return (
|
|
|
|
<Flex justify="space-between" align="center">
|
|
|
|
<Text>Background color:</Text>
|
|
|
|
<ColorPicker
|
2022-01-24 15:07:09 +01:00
|
|
|
initialColor={background.content ?? defaultBackgroundColor}
|
2021-12-23 09:37:42 +01:00
|
|
|
onColorChange={handleContentChange}
|
|
|
|
/>
|
|
|
|
</Flex>
|
|
|
|
)
|
|
|
|
case BackgroundType.IMAGE:
|
|
|
|
return (
|
|
|
|
<Flex>
|
|
|
|
<Text>Image</Text>
|
|
|
|
</Flex>
|
|
|
|
)
|
|
|
|
default:
|
|
|
|
return <></>
|
|
|
|
}
|
|
|
|
}
|