ldc-ovoteam/resources/ts/back/Components/Layout/Settings/Sections/Themes.tsx
Jérémy Munsch cd2d8ed397
refactor(i18n): replace GetTranslation with trans function
- Updated translation utility to improve consistency and reduce redundancy.
- Removed deprecated useTrans hook and related code.
- Introduced a new Zustand store for managing translations and locale settings.
- Cleaned up unused hooks and files related to localization.
2026-10-19 17:43:33 +02:00

59 lines
1.6 KiB
TypeScript

import { MoonIcon, SunIcon } from "lucide-react";
import { useTheme } from "@/back/providers/ThemeProvider";
import type { Theme } from "@/back/types/global";
import { Button } from "@/components/ui/button";
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
import trans from "@/hooks/use-translations";
import { cn } from "@/lib/utils";
export default function Themes() {
const { setTheme, theme } = useTheme();
const mods = [
{
name: trans("uwil-backend::back.light"),
theme: "light",
icon: SunIcon,
},
{
name: trans("uwil-backend::back.dark"),
theme: "dark",
icon: MoonIcon,
},
];
return (
<>
<p className="text-center text-muted-foreground text-sm font-medium leading-7">
{trans("uwil-backend::back.mods")}
</p>
<div className="flex flex-row justify-center items-center gap-1">
{mods.map((mod) => {
return (
<DropdownMenuItem
key={mod.name}
className="p-0"
onSelect={(e) => {
e.preventDefault();
}}
>
<Button
className={cn("w-full", {
"bg-secondary": theme === mod.theme,
})}
variant="ghost"
onClick={() => {
setTheme(mod.theme as Theme);
}}
>
<mod.icon />
{trans(mod.name)}
</Button>
</DropdownMenuItem>
);
})}
</div>
</>
);
}