2021-12-23 09:37:42 +01:00
|
|
|
import {
|
|
|
|
AccordionItem,
|
|
|
|
AccordionButton,
|
|
|
|
HStack,
|
|
|
|
Heading,
|
|
|
|
AccordionIcon,
|
|
|
|
AccordionPanel,
|
|
|
|
Stack,
|
|
|
|
} from '@chakra-ui/react'
|
|
|
|
import { PencilIcon } from 'assets/icons'
|
2022-01-06 09:40:56 +01:00
|
|
|
import { Background } from 'models'
|
|
|
|
import { useTypebot } from 'contexts/TypebotContext/TypebotContext'
|
2021-12-23 09:37:42 +01:00
|
|
|
import React from 'react'
|
|
|
|
import { BackgroundSelector } from './BackgroundSelector'
|
|
|
|
import { FontSelector } from './FontSelector'
|
|
|
|
|
|
|
|
export const GeneralContent = () => {
|
2022-01-06 09:40:56 +01:00
|
|
|
const { typebot, updateTypebot } = useTypebot()
|
2021-12-23 09:37:42 +01:00
|
|
|
|
|
|
|
const handleSelectFont = (font: string) => {
|
|
|
|
if (!typebot) return
|
2022-01-06 09:40:56 +01:00
|
|
|
updateTypebot({
|
|
|
|
theme: {
|
|
|
|
...typebot.theme,
|
|
|
|
general: { ...typebot.theme.general, font },
|
|
|
|
},
|
2021-12-23 09:37:42 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const handleBackgroundChange = (background: Background) => {
|
|
|
|
if (!typebot) return
|
2022-01-06 09:40:56 +01:00
|
|
|
updateTypebot({
|
|
|
|
theme: {
|
|
|
|
...typebot.theme,
|
|
|
|
general: { ...typebot.theme.general, background },
|
|
|
|
},
|
2021-12-23 09:37:42 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<AccordionItem>
|
|
|
|
<AccordionButton py={6}>
|
|
|
|
<HStack flex="1" pl={2}>
|
|
|
|
<PencilIcon />
|
|
|
|
<Heading fontSize="lg" color="gray.700">
|
|
|
|
General
|
|
|
|
</Heading>
|
|
|
|
</HStack>
|
|
|
|
<AccordionIcon />
|
|
|
|
</AccordionButton>
|
|
|
|
{typebot && (
|
|
|
|
<AccordionPanel as={Stack} pb={4} spacing={6}>
|
|
|
|
<FontSelector
|
|
|
|
activeFont={typebot.theme.general.font}
|
|
|
|
onSelectFont={handleSelectFont}
|
|
|
|
/>
|
|
|
|
<BackgroundSelector
|
|
|
|
initialBackground={typebot.theme.general.background}
|
|
|
|
onBackgroundChange={handleBackgroundChange}
|
|
|
|
/>
|
|
|
|
</AccordionPanel>
|
|
|
|
)}
|
|
|
|
</AccordionItem>
|
|
|
|
)
|
|
|
|
}
|