import { useCallback } from 'react' import { useTheme } from 'next-themes' import { fs, joinPath } from '@janhq/core' import { Button, Select, Switch } from '@janhq/joi' import { useAtom, useAtomValue } from 'jotai' import { twMerge } from 'tailwind-merge' import { janDataFolderPathAtom } from '@/helpers/atoms/AppConfig.atom' import { chatWidthAtom, reduceTransparentAtom, selectedThemeIdAtom, showScrollBarAtom, spellCheckAtom, themeDataAtom, themesOptionsAtom, } from '@/helpers/atoms/Setting.atom' export default function AppearanceOptions() { const [selectedIdTheme, setSelectedIdTheme] = useAtom(selectedThemeIdAtom) const themeOptions = useAtomValue(themesOptionsAtom) const janDataFolderPath = useAtomValue(janDataFolderPathAtom) const { setTheme, theme } = useTheme() const [themeData, setThemeData] = useAtom(themeDataAtom) const [reduceTransparent, setReduceTransparent] = useAtom( reduceTransparentAtom ) const [spellCheck, setSpellCheck] = useAtom(spellCheckAtom) const [showScrollBar, setShowScrollBar] = useAtom(showScrollBarAtom) const [chatWidth, setChatWidth] = useAtom(chatWidthAtom) const chatWidthOption = [ { name: 'Full Width', value: 'full', img: 'images/full-width.png', darkImg: 'images/full-width-dark.png', }, { name: 'Compact Width', value: 'compact', img: 'images/compact-width.png', darkImg: 'images/compact-width-dark.png', }, ] const handleClickTheme = useCallback( async (e: string) => { setSelectedIdTheme(e) const janThemesPath = await joinPath([janDataFolderPath, 'themes']) const filePath = await joinPath([`${janThemesPath}/${e}`, `theme.json`]) const theme: Theme = JSON.parse(await fs.readFileSync(filePath, 'utf-8')) setThemeData(theme) setTheme(String(theme?.nativeTheme)) if (theme?.reduceTransparent) { setReduceTransparent(reduceTransparent) } else { setReduceTransparent(true) } }, [ janDataFolderPath, reduceTransparent, setReduceTransparent, setSelectedIdTheme, setTheme, setThemeData, ] ) return (
Appearance

Select a color theme.