// ThemeToggle.tsx import React from "react"; import { useTheme } from "../hooks/useTheme"; // Actual primary colors for each theme const themeColors: Record = { a: { primary: "#3d8eff", label: "Blue" }, b: { primary: "#ff7043", label: "Ember" }, c: { primary: "#00a3c4", label: "Teal" }, d: { primary: "#7743d8", label: "Violet" }, e: { primary: "#00d2a2", label: "Emerald" }, }; export function ThemeToggle({ compact = false }: { compact?: boolean }) { const { theme, setTheme } = useTheme(); const themes = ["a", "b", "c", "d", "e"] as const; const crossfadeTo = (next: typeof themes[number]) => { // 1) capture current hero computed background (all layers resolved) const hero = document.querySelector(".bg-hero"); const prevBg = hero ? getComputedStyle(hero).backgroundImage : ""; // 2) stash it in a CSS var & flag crossfade const root = document.documentElement; root.style.setProperty("--hero-bg-prev", prevBg); root.classList.add("hero-xfade"); // 3) switch theme (your existing logic) setTheme(next as any); // 4) remove crossfade flag after the animation window.setTimeout(() => { root.classList.remove("hero-xfade"); root.style.removeProperty("--hero-bg-prev"); }, 600); // a bit > .55s animation }; return (
{compact ? "Theme" : "Toggle Theme"}
    {themes.map((t) => (
  • ))}
); }