import { useEffect } from 'react'; import { IconCheck, IconMoon, IconSun, IconPalette } from '@tabler/icons-react'; import { useTranslation } from 'react-i18next'; import { cn } from '@/lib/utils'; import { useTheme } from '@/context/theme-context'; import { Button } from '@/components/ui/button'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; export function ThemeSwitch() { const { theme, setTheme, colorScheme, setColorScheme } = useTheme(); const { t } = useTranslation(); const colorSchemes = [ { name: 'blue', label: t('theme.colors.blue'), color: 'bg-blue-500' }, { name: 'green', label: t('theme.colors.green'), color: 'bg-green-500' }, { name: 'purple', label: t('theme.colors.purple'), color: 'bg-purple-500' }, { name: 'orange', label: t('theme.colors.orange'), color: 'bg-orange-500' }, { name: 'red', label: t('theme.colors.red'), color: 'bg-red-500' }, { name: 'black', label: t('theme.colors.black'), color: 'bg-black' }, { name: 'cream', label: t('theme.colors.cream'), color: 'bg-amber-100' }, { name: 'claude', label: t('theme.colors.claude'), color: 'bg-amber-600' }, { name: 'starry', label: t('theme.colors.starry'), color: 'bg-blue-600' }, ] as const; /* Update theme-color meta tag when theme is updated */ useEffect(() => { const themeColor = theme === 'dark' ? '#020817' : '#fff'; const metaThemeColor = document.querySelector("meta[name='theme-color']"); if (metaThemeColor) metaThemeColor.setAttribute('content', themeColor); }, [theme]); return ( setTheme('light')}> {t('theme.light')} setTheme('dark')}> {t('theme.dark')} setTheme('system')}> {t('theme.system')} {t('theme.colorScheme')}
s.name === colorScheme)?.color || 'bg-blue-500')} /> {colorSchemes.map((scheme) => ( setColorScheme(scheme.name)} className='flex items-center justify-between'>
{scheme.label}
))} ); }