Skip to content

Commit

Permalink
fix: localStorage key (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
ollema authored Feb 11, 2024
1 parent 08ae7a0 commit 758cb39
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/green-panthers-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'mode-watcher': patch
---

Fix incorrect localStorage key
3 changes: 2 additions & 1 deletion src/lib/mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function resetMode(): void {
userPrefersMode.set('system');
}

/** Used to set the mode on initial page load to prevent FOUC */
export function setInitialMode(defaultMode: Mode, themeColors?: ThemeColors) {
const rootEl = document.documentElement;
const mode = localStorage.getItem('mode-watcher-mode') || defaultMode;
Expand All @@ -40,7 +41,7 @@ export function setInitialMode(defaultMode: Mode, themeColors?: ThemeColors) {
}
}

localStorage.setItem('mode', mode);
localStorage.setItem('mode-watcher-mode', mode);
}

export { localStorageKey, userPrefersMode, systemPrefersMode, derivedMode as mode, themeColors };

0 comments on commit 758cb39

Please sign in to comment.