{isOpen && (
<>
setIsOpen(false)}
aria-hidden="true"
/>
{themes.map((t) => (
))}
>
)}
);
}
// ============================================
// Utility: Apply theme class to body
// ============================================
export function useThemeClass() {
const { effectiveTheme } = useTheme();
useEffect(() => {
const root = window.document.documentElement;
root.classList.remove('light', 'dark');
root.classList.add(effectiveTheme);
root.setAttribute('data-theme', effectiveTheme);
}, [effectiveTheme]);
}
// ============================================
// Higher-Order Component for Theme
// ============================================
export function withTheme
(
Component: React.ComponentType
) {
return function ThemedComponent(props: P) {
const theme = useTheme();
return ;
};
}