2
0
Files
bot/apps/builder/components/theme/GeneralSettings/BackgroundSelector/BackgroundContent.tsx

41 lines
1.0 KiB
TypeScript
Raw Normal View History

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 = {
background?: Background
2021-12-23 09:37:42 +01:00
onBackgroundContentChange: (content: string) => void
}
const defaultBackgroundColor = '#ffffff'
2021-12-23 09:37:42 +01:00
export const BackgroundContent = ({
background,
onBackgroundContentChange,
}: BackgroundContentProps) => {
const handleContentChange = (content: string) =>
onBackgroundContentChange(content)
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
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 <></>
}
}