Skip to content

Commit

Permalink
Merge pull request #879 from vizhub-core/theme-persist
Browse files Browse the repository at this point in the history
Theme persist
  • Loading branch information
curran authored Nov 27, 2024
2 parents 9db5162 + 14ebb7d commit fdb1c7b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/client/VZSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,21 @@ export const VZSettings = ({

const handleThemeChange = useCallback(
(event: React.ChangeEvent<HTMLSelectElement>) => {
setTheme(event.target.value as ThemeLabel);
const selectedTheme = event.target.value as ThemeLabel;
setTheme(selectedTheme);
localStorage.setItem('vzcodeSelectedTheme', selectedTheme);
},
[],
);


useEffect(() => {
const savedTheme = localStorage.getItem('vzcodeSelectedTheme') as ThemeLabel | null;
if (savedTheme) {
setTheme(savedTheme);
} else {
setTheme('vizhub');
}
}, [setTheme]);
// Initialize font and size from localStorage or defaults
// const [selectedFont, setSelectedFont] = useState(
// localStorage.getItem('vzcodeSelectedFont') ||
Expand Down

0 comments on commit fdb1c7b

Please sign in to comment.