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 { janThemesPathAtom, reduceTransparentAtom, selectedThemeIdAtom, spellCheckAtom, themeDataAtom, themesOptionsAtom, } from '@/helpers/atoms/Setting.atom' export default function AppearanceOptions() { const [selectedIdTheme, setSelectedIdTheme] = useAtom(selectedThemeIdAtom) const themeOptions = useAtomValue(themesOptionsAtom) const { setTheme } = useTheme() const janThemesPath = useAtomValue(janThemesPathAtom) const [themeData, setThemeData] = useAtom(themeDataAtom) const [reduceTransparent, setReduceTransparent] = useAtom( reduceTransparentAtom ) const [spellCheck, setSpellCheck] = useAtom(spellCheckAtom) const handleClickTheme = useCallback( async (e: string) => { setSelectedIdTheme(e) 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) } }, [ janThemesPath, reduceTransparent, setReduceTransparent, setSelectedIdTheme, setTheme, setThemeData, ] ) return (
Select a color theme
Disable if you prefer to type without spell checking interruptions or if you are using non-standard language/terminology that the spell checker may not recognize.