disable light mode (#271)

This commit is contained in:
Kerem Yilmaz
2024-05-07 12:54:59 -07:00
committed by GitHub
parent 5ce37dfaaf
commit 7b36e04418
3 changed files with 3 additions and 9 deletions

View File

@@ -7,7 +7,7 @@ import { queryClient } from "./api/QueryClient";
function App() {
return (
<QueryClientProvider client={queryClient}>
<ThemeProvider defaultTheme="dark" storageKey="skyvern-theme">
<ThemeProvider defaultTheme="dark">
<RouterProvider router={router} />
</ThemeProvider>
</QueryClientProvider>

View File

@@ -4,22 +4,17 @@ import { Theme, ThemeProviderContext } from "./themeProviderContext";
export type ThemeProviderProps = {
children: React.ReactNode;
defaultTheme?: Theme;
storageKey?: string;
};
export function ThemeProvider({
children,
defaultTheme = "system",
storageKey = "vite-ui-theme",
...props
}: ThemeProviderProps) {
const [theme, setTheme] = useState<Theme>(
() => (localStorage.getItem(storageKey) as Theme) || defaultTheme,
);
const [theme, setTheme] = useState<Theme>(defaultTheme);
useEffect(() => {
const root = window.document.documentElement;
root.classList.remove("light", "dark");
if (theme === "system") {
@@ -38,7 +33,6 @@ export function ThemeProvider({
const value = {
theme,
setTheme: (theme: Theme) => {
localStorage.setItem(storageKey, theme);
setTheme(theme);
},
};

View File

@@ -8,7 +8,7 @@ type ThemeProviderState = {
};
const initialState: ThemeProviderState = {
theme: "system",
theme: "dark",
setTheme: () => null,
};