import { ThemeProvider as EmotionThemeProvider, Global, css, } from "@emotion/react"; import { useMemo } from "react"; import { ReactNode } from "react"; import { useSnapshot } from "valtio"; import d_theme, { state } from "./theme"; type DeepPartial = Partial<{ [P in keyof T]: DeepPartial }>; interface IThemeProvider { theme?: DeepPartial; children: ReactNode; } const ThemeProvider: React.FC = (props) => { const { theme, children, ...rest } = props; const { type } = useSnapshot(state); const _bg = useMemo(() => new Map(), [type]) .set("light", "rgba(255, 255, 255, 1)") .set("dark", "rgba(0, 0, 0, 1)") .get(type) as string; const _color = useMemo(() => new Map(), [type]) .set("light", "rgba(0, 0, 0, 1)") .set("dark", "rgba(232, 222, 248, 1)") .get(type) as string; // Override the default theme with the one passed in const app_theme = Object.assign(d_theme, theme); return ( {children} ); }; export default ThemeProvider;