import { Form, Input, Button, InputNumber, Card, Radio, message } from 'antd'; import { useTheme } from '../../../contexts/ThemeContext'; import { useI18n } from '../../../i18n'; interface ThemeKeyMap { MODE: string; PRIMARY: string; RADIUS: string; TOKENS: string; CSS: string; } interface AppearanceSettingsTabProps { config: Record; loading: boolean; onSave: (values: Record) => Promise; themeKeys: ThemeKeyMap; } export default function AppearanceSettingsTab({ config, loading, onSave, themeKeys, }: AppearanceSettingsTabProps) { const { previewTheme } = useTheme(); const { t } = useI18n(); return (
{ try { const tokens = all[themeKeys.TOKENS] ? JSON.parse(all[themeKeys.TOKENS]) : undefined; previewTheme({ mode: all[themeKeys.MODE], primaryColor: all[themeKeys.PRIMARY], borderRadius: typeof all[themeKeys.RADIUS] === 'number' ? all[themeKeys.RADIUS] : undefined, customTokens: tokens, customCSS: all[themeKeys.CSS], }); } catch { previewTheme({ mode: all[themeKeys.MODE], primaryColor: all[themeKeys.PRIMARY], borderRadius: typeof all[themeKeys.RADIUS] === 'number' ? all[themeKeys.RADIUS] : undefined, customCSS: all[themeKeys.CSS], }); } }} onFinish={async (vals) => { if (vals[themeKeys.TOKENS]) { try { JSON.parse(String(vals[themeKeys.TOKENS])); } catch { message.error(t('Advanced tokens must be valid JSON')); return; } } await onSave(vals); }} style={{ marginTop: 24 }} key={'appearance-' + JSON.stringify(config)} > {t('Light')} {t('Dark')} {t('Follow System')}
); }