import { useState } from 'react'; import { Button, ConfirmModal, Switch, Text, Textarea } from '/@/renderer/components'; import { sanitizeCss } from '/@/renderer/utils/sanitize'; import { Code } from '@mantine/core'; import { SettingsOptions } from '/@/renderer/features/settings/components/settings-option'; import { closeAllModals, openModal } from '@mantine/modals'; import { useTranslation } from 'react-i18next'; import { useCssSettings, useSettingsStoreActions } from '/@/renderer/store'; export const StylesSettings = () => { const [open, setOpen] = useState(false); const { t } = useTranslation(); const { enabled, content } = useCssSettings(); const [css, setCss] = useState(content); const { setSettings } = useSettingsStoreActions(); const handleSave = () => { setSettings({ css: { content: css, enabled, }, }); }; const handleResetToDefault = () => { setSettings({ css: { content, enabled: true, }, }); closeAllModals(); }; const openConfirmModal = () => { openModal({ children: ( {t('setting.customCssNotice', { postProcess: 'sentenceCase' })} ), title: t('setting.customCssEnable', { postProcess: 'sentenceCase' }), }); }; return ( <> { if (!e.currentTarget.checked) { setSettings({ css: { content, enabled: false, }, }); } else { openConfirmModal(); } }} /> } description={t('setting.customCssEnable', { context: 'description', postProcess: 'sentenceCase', })} title={t('setting.customCssEnable', { postProcess: 'sentenceCase' })} /> {enabled && ( <> {open && ( )} } description={t('setting.customCss', { context: 'description', postProcess: 'sentenceCase', })} title={t('setting.customCss', { postProcess: 'sentenceCase' })} /> {open && ( <>