claude-code-best/packages/remote-control-server/web/components/ui/theme-toggle.tsx
James Feng 056231d02b feat: 支持 acp-link 包进行 acp 通用的 remote-control (#292)
Commit: 34154ee
142 files changed — React Web UI 迁移 + acp-link 完善
2026-06-04 23:52:35 +08:00

48 lines
1.5 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>
);
}