echoes/frontend/hooks/theme/themeManager.tsx

34 lines
655 B
TypeScript

// components/theme/themeManager.tsx
import React, { useEffect } from 'react';
import { useThemeLoader } from './useThemeLoader';
interface ThemeManagerProps {
themeName: string;
children: React.ReactNode;
}
export const ThemeManager: React.FC<ThemeManagerProps> = ({
themeName,
children
}) => {
const { theme, loading, error } = useThemeLoader(themeName);
if (loading) {
return <div>...</div>;
}
if (error) {
return <div>: {error}</div>;
}
if (!theme) {
return <div></div>;
}
return (
<div className={`theme-${themeName}`}>
{children}
</div>
);
};