/** * @file AppearanceSettings.tsx * @description Settings → Appearance: the Dark / Light / System mode switch and * one named-theme picker per mode (state in `hooks/useTheme.ts`, palettes in * `index.css`). Each card's swatch re-scopes the theme's CSS variables on its * own element (`dark` class or `data-mode`, plus `data-theme`), so the preview * is painted by the same tokens as the app — no hex is duplicated here. * @author Nguyễn Ngọc Trí Vĩ */ import { useTranslation } from "react-i18next"; import { Monitor, Moon, Palette, Sun } from "lucide-react"; import { THEMES, useTheme, type Theme, type ThemeMode } from "../../hooks/useTheme"; const THEME_LABELS: Record = { darcula: "Darcula", "apple-dark": "Apple Dark", "apple-light": "Apple Light", "intellij-light": "IntelliJ Light", canvas: "Canvas", }; const MODES: { mode: ThemeMode; Icon: typeof Moon }[] = [ { mode: "dark", Icon: Moon }, { mode: "light", Icon: Sun }, { mode: "system", Icon: Monitor }, ]; function Swatch({ mode, name }: { mode: Theme; name: string }) { return (
const{" "} x{" "} ={" "} "ok"
); } export function AppearanceSettings() { const { t } = useTranslation("settings"); const { mode, theme, themeFor, setMode, setThemeFor } = useTheme(); return (

{t("appearance.title")}

{t("appearance.description")}

{t("appearance.mode")}

{MODES.map(({ mode: m, Icon }) => ( ))}
{(["dark", "light"] as const).map((group) => (

{t(`appearance.${group}Themes`)} {theme === group && ( {t("appearance.active")} )}

{THEMES[group].map((name) => { const selected = themeFor[group] === name; const label = THEME_LABELS[name] ?? t("appearance.default"); return ( ); })}
))}
); }