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() { function App() {
return ( return (
<QueryClientProvider client={queryClient}> <QueryClientProvider client={queryClient}>
<ThemeProvider defaultTheme="dark" storageKey="skyvern-theme"> <ThemeProvider defaultTheme="dark">
<RouterProvider router={router} /> <RouterProvider router={router} />
</ThemeProvider> </ThemeProvider>
</QueryClientProvider> </QueryClientProvider>

View File

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

View File

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