mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-15 21:05:51 +00:00
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { Moon, Sun, Monitor } from 'lucide-react';
|
|
import { useTheme, type Theme } from '../../src/lib/theme';
|
|
import { Button } from './button';
|
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from './dropdown-menu';
|
|
|
|
const themeOptions: { value: Theme; label: string; icon: React.ReactNode }[] = [
|
|
{ value: 'light', label: 'Light', icon: <Sun className="h-4 w-4" /> },
|
|
{ value: 'dark', label: 'Dark', icon: <Moon className="h-4 w-4" /> },
|
|
{ value: 'system', label: 'System', icon: <Monitor className="h-4 w-4" /> },
|
|
];
|
|
|
|
export function ThemeToggle() {
|
|
const { theme, setTheme, resolvedTheme } = useTheme();
|
|
|
|
return (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button variant="ghost" size="icon" className="h-8 w-8">
|
|
{resolvedTheme === 'dark' ? <Moon className="h-4 w-4" /> : <Sun className="h-4 w-4" />}
|
|
<span className="sr-only">Toggle theme</span>
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end">
|
|
{themeOptions.map(option => (
|
|
<DropdownMenuItem
|
|
key={option.value}
|
|
onClick={() => setTheme(option.value)}
|
|
className={theme === option.value ? 'bg-accent' : ''}
|
|
>
|
|
{option.icon}
|
|
<span className="ml-2">{option.label}</span>
|
|
</DropdownMenuItem>
|
|
))}
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
);
|
|
}
|