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

38 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-12-23 09:37:42 +01:00
import { Stack, Text } from '@chakra-ui/react'
2022-01-06 09:40:56 +01:00
import { Background, BackgroundType } from 'models'
import React from 'react'
2021-12-23 09:37:42 +01:00
import { BackgroundContent } from './BackgroundContent'
import { BackgroundTypeRadioButtons } from './BackgroundTypeRadioButtons'
type Props = {
background?: Background
2021-12-23 09:37:42 +01:00
onBackgroundChange: (newBackground: Background) => void
}
const defaultBackgroundType = BackgroundType.NONE
2021-12-23 09:37:42 +01:00
export const BackgroundSelector = ({
background,
2021-12-23 09:37:42 +01:00
onBackgroundChange,
}: Props) => {
const handleBackgroundTypeChange = (type: BackgroundType) =>
background && onBackgroundChange({ ...background, type })
2021-12-23 09:37:42 +01:00
const handleBackgroundContentChange = (content: string) =>
background && onBackgroundChange({ ...background, content })
2021-12-23 09:37:42 +01:00
return (
<Stack spacing={4}>
<Text>Background</Text>
<BackgroundTypeRadioButtons
backgroundType={background?.type ?? defaultBackgroundType}
2021-12-23 09:37:42 +01:00
onBackgroundTypeChange={handleBackgroundTypeChange}
/>
<BackgroundContent
background={background}
2021-12-23 09:37:42 +01:00
onBackgroundContentChange={handleBackgroundContentChange}
/>
</Stack>
)
}