- Installation de next-themes - Création du composant ThemeToggle avec icônes soleil/lune - Intégration du ThemeProvider dans le layout - Ajout du toggle dans la navigation mobile et le header admin - Adaptation des couleurs pour le dark mode (tropical chic) - Mise à jour des composants UI (Card, Button) pour le dark mode - Adaptation des composants principaux (Layout, WifiCard, etc.)
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
"use client";
|
|
|
|
import { useTheme } from "next-themes";
|
|
import { Moon, Sun } from "lucide-react";
|
|
import { Button } from "@/components/ui/button";
|
|
import { useEffect, useState } from "react";
|
|
|
|
export function ThemeToggle() {
|
|
const { theme, setTheme } = useTheme();
|
|
const [mounted, setMounted] = useState(false);
|
|
|
|
useEffect(() => {
|
|
setMounted(true);
|
|
}, []);
|
|
|
|
if (!mounted) {
|
|
return (
|
|
<Button
|
|
variant="ghost"
|
|
size="icon"
|
|
className="h-9 w-9 rounded-full"
|
|
aria-label="Changer de thème"
|
|
>
|
|
<Sun className="h-5 w-5" />
|
|
</Button>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Button
|
|
variant="ghost"
|
|
size="icon"
|
|
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
|
|
className="h-10 w-10 rounded-full hover:bg-secondary dark:hover:bg-gray-800"
|
|
aria-label="Changer de thème"
|
|
>
|
|
{theme === "dark" ? (
|
|
<Sun className="h-5 w-5 text-primary dark:text-yellow-400" />
|
|
) : (
|
|
<Moon className="h-5 w-5 text-primary dark:text-blue-300" />
|
|
)}
|
|
</Button>
|
|
);
|
|
}
|
|
|