Skip to content

Commit

Permalink
Use local storage to remember user's theme preference (opendatahub-io…
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-phillips-18 authored Dec 6, 2024
1 parent 966c055 commit 70e0d4e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion frontend/src/app/ThemeContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import { useBrowserStorage } from '~/components/browserStorage';

type ThemeContextProps = {
theme: string;
Expand All @@ -14,7 +15,7 @@ type ThemeProviderProps = {
children: React.ReactNode;
};
export const ThemeProvider: React.FC<ThemeProviderProps> = ({ children }) => {
const [theme, setTheme] = React.useState('light');
const [theme, setTheme] = useBrowserStorage<string>('odh.dashboard.ui.theme', 'light');

const contextValue = React.useMemo(() => ({ theme, setTheme }), [theme, setTheme]);

Expand Down

0 comments on commit 70e0d4e

Please sign in to comment.