import { useStore } from '@nanostores/react' import { type Locale, LOCALE_META, useI18n } from '@/i18n' import { triggerHaptic } from '@/lib/haptics' import { Check, Palette } from '@/lib/icons' import { cn } from '@/lib/utils' import { $toolViewMode, setToolViewMode } from '@/store/tool-view' import { useTheme } from '@/themes/context' import { BUILTIN_THEMES } from '@/themes/presets' import { MODE_OPTIONS } from './constants' import { Pill, SectionHeading, SettingsContent } from './primitives' function ThemePreview({ name }: { name: string }) { const t = BUILTIN_THEMES[name] if (!t) { return null } const c = t.colors return (
) } export function AppearanceSettings() { const { t, locale, setLocale } = useI18n() const { themeName, mode, availableThemes, setTheme, setMode } = useTheme() const toolViewMode = useStore($toolViewMode) const activeTheme = availableThemes.find(theme => theme.name === themeName) const a = t.settings.appearance const locales = Object.keys(LOCALE_META) as Locale[] return (

{a.intro}

{t.language.label}
{t.language.description}
{LOCALE_META[locale].name}
{locales.map(code => { const active = locale === code return ( ) })}
{a.colorMode}
{a.colorModeDesc}
{t.settings.modeOptions[mode].label}
{MODE_OPTIONS.map(({ id, icon: Icon }) => { const active = mode === id const copy = t.settings.modeOptions[id] return ( ) })}
{a.toolViewTitle}
{a.toolViewDesc}
{toolViewMode === 'technical' ? a.technical : a.product}
{( [ { id: 'product', label: a.product, description: a.productDesc }, { id: 'technical', label: a.technical, description: a.technicalDesc } ] as const ).map(option => { const active = toolViewMode === option.id return ( ) })}
{a.themeTitle}
{a.themeDesc}
{activeTheme && {activeTheme.label}}
{availableThemes.map(theme => { const active = themeName === theme.name return ( ) })}
) }