import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { MdPalette } from "react-icons/md"; interface ThemeOption { name: string; displayName: string; displayColor: string; } const themeOptions: ThemeOption[] = [ { name: "pink", displayName: "Light Pink", displayColor: "oklch(65% 0.241 354.308)", }, { name: "ocean", displayName: "Ocean Breeze", displayColor: "oklch(70% 0.18 220)", }, { name: "mint", displayName: "Mint Leaf", displayColor: "oklch(65% 0.16 160)", }, { name: "glow", displayName: "Golden Glow", displayColor: "oklch(70% 0.16 70)", }, ]; export function ThemeSwitcher() { const [currentTheme, setCurrentTheme] = useState("pink"); const { t } = useTranslation(); useEffect(() => { const savedTheme = localStorage.getItem("theme") || "pink"; setCurrentTheme(savedTheme); applyTheme(savedTheme); }, []); const applyTheme = (themeName: string) => { const root = document.documentElement; root.setAttribute("data-theme", themeName); }; const handleThemeChange = (themeName: string) => { setCurrentTheme(themeName); applyTheme(themeName); localStorage.setItem("theme", themeName); const activeElement = document.activeElement as HTMLElement; if (activeElement) { activeElement.blur(); } }; return (
); }