fix: theme

This commit is contained in:
2026-08-21 10:18:18 +03:30
parent b4d8e32fdd
commit faf95327f1
4 changed files with 94 additions and 31 deletions
+17 -5
View File
@@ -1,21 +1,33 @@
"use client";
import { useTheme } from "@/lib/theme";
import { SunIcon, MoonIcon } from "./icons";
import { SunIcon, MoonIcon, MonitorIcon } from "./icons";
const LABELS = {
light: "حالت روشن",
dark: "حالت تاریک",
system: "حالت سیستم",
};
const ICONS = {
light: SunIcon,
dark: MoonIcon,
system: MonitorIcon,
};
export function ThemeToggle({ className }: { className?: string }) {
const { theme, toggle } = useTheme();
const dark = theme === "dark";
const Icon = ICONS[theme];
return (
<button
type="button"
onClick={toggle}
aria-label={dark ? "حالت روشن" : "حالت تاریک"}
title={dark ? "حالت روشن" : "حالت تاریک"}
aria-label={LABELS[theme]}
title={LABELS[theme]}
className={`rounded-lg p-2 text-muted transition hover:bg-surface-muted hover:text-foreground ${className ?? ""}`}
>
{dark ? <SunIcon className="h-5 w-5" /> : <MoonIcon className="h-5 w-5" />}
<Icon className="h-5 w-5" />
</button>
);
}