This commit is contained in:
2026-03-22 17:03:54 +08:00
parent 8e76dd7a7b
commit 5c6d8c6b92
49 changed files with 203 additions and 1442 deletions

View File

@@ -0,0 +1,32 @@
import { useState, type ReactNode } from "react";
import { type Theme, ThemeContext } from "./ThemeContext";
import { cn } from "tailwind-variants";
type ThemeProviderProps = {
children?: ReactNode;
defaultTheme?: Theme;
};
export const ThemeProvider = ({
children,
defaultTheme,
}: ThemeProviderProps) => {
const [theme, setTheme] = useState<Theme>(defaultTheme || "light");
const toggleTheme = () => setTheme(theme === "light" ? "dark" : "light");
const frameworkClass = "dg";
const themeClass = cn(frameworkClass, theme);
return (
<ThemeContext.Provider value={{ theme, toggleTheme, themeClass }}>
<div
className={"dg-theme-provider"}
style={
theme == "light" ? { background: "white" } : { background: "black" }
}
>
{children}
</div>
</ThemeContext.Provider>
);
};