Skip to content

Commit

Permalink
Merge pull request #198 from lincolnpjames/persist-dark-mode
Browse files Browse the repository at this point in the history
Use localStorage to store theme preference
  • Loading branch information
Hunter275 authored Jun 17, 2024
2 parents 7742a3e + e47738d commit c3116c0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/stores/appStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const useAppStore = create<AppState>()((set) => ({
currentPage: "messages",
rasterSources: [],
commandPaletteOpen: false,
darkMode: window.matchMedia("(prefers-color-scheme: dark)").matches,
darkMode: (localStorage.getItem('theme-dark') !== null ? (localStorage.getItem('theme-dark') === 'true' ? true : false) : window.matchMedia("(prefers-color-scheme: dark)").matches),
accent: "orange",
connectDialogOpen: false,
nodeNumToBeRemoved: 0,
Expand Down Expand Up @@ -96,6 +96,7 @@ export const useAppStore = create<AppState>()((set) => ({
);
},
setDarkMode: (enabled: boolean) => {
localStorage.setItem('theme-dark', enabled.toString());
set(
produce<AppState>((draft) => {
draft.darkMode = enabled;
Expand Down

0 comments on commit c3116c0

Please sign in to comment.