peppa/apps/web/components/ThemeToggle.tsx
Асель 28fbde4add PEP-38: console foundation — Tailwind v4, shadcn/ui components, dark theme, three-panel layout
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 16:21:43 +05:00

20 lines
725 B
TypeScript

"use client";
import { Moon, Sun } from "lucide-react";
import { Button } from "@/components/ui/button";
import { THEME_COOKIE } from "@/lib/theme";
/** Dark ⇄ light; the choice lives in a cookie for a year (the root layout reads it). */
export function ThemeToggle() {
const toggle = () => {
const dark = document.documentElement.classList.toggle("dark");
document.cookie = `${THEME_COOKIE}=${dark ? "dark" : "light"}; path=/; max-age=31536000; samesite=lax`;
};
return (
<Button variant="ghost" size="icon-sm" onClick={toggle} aria-label="Сменить тему" title="Сменить тему">
<Sun className="hidden dark:block" />
<Moon className="dark:hidden" />
</Button>
);
}