import { Monitor, Moon, Sun } from 'lucide-react'; import { motion } from 'motion/react'; import { paletteResolved, useTheme, type ThemeMode } from '@/contexts/ThemeContext'; import { cn } from '@/lib/utils'; const OPTIONS: { mode: ThemeMode; icon: typeof Sun; label: string }[] = [ { mode: 'system', icon: Monitor, label: '跟随系统' }, { mode: 'light', icon: Sun, label: '浅色' }, { mode: 'dark', icon: Moon, label: '深色' }, ]; export function ThemeToggle({ className }: { className?: string }) { const { appearance, mode, setMode, managedBy } = useTheme(); // A Catppuccin flavor fixes light/dark, so this quick toggle would be inert // (and its pill would desync from the forced scheme) — hide it. Light/dark is // then changed by switching the palette back to “默认” in settings. if (managedBy || paletteResolved(appearance.palette)) { return null; } return (
{OPTIONS.map(({ mode: m, icon: Icon, label }) => { const active = mode === m; return ( ); })}
); }