Skip to content

Commit 5385ee6

Browse files
committed
theme is now localstorage by default
1 parent 99e3a18 commit 5385ee6

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/js/components/navbar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ window.addEventListener("load", () => {
4949
const anchor = child.getElementsByTagName("a")[0];
5050
anchor.text = Theme.unicodeIcon;
5151
child.addEventListener("click", () => {
52-
anchor.text = Theme.fromExisting().reverse(sessionStorage, (theme) => {
52+
anchor.text = Theme.fromExisting().reverse(localStorage, (theme) => {
5353
if (typeof themeCssMap === "undefined") return;
5454
removeFileFromHead(themeCssMap[theme.opposite.theme]);
5555
addCssFile(themeCssMap[theme.theme]);

src/js/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,11 @@ class Theme {
533533
* @returns {"dark" | "light"}
534534
*/
535535
static #fromExisting = (storagePriorty = null) => {
536-
const pStore = storagePriorty || sessionStorage || localStorage;
537-
const secStore = pStore === sessionStorage ? localStorage : sessionStorage;
536+
const pStore = storagePriorty || localStorage || sessionStorage;
537+
const secStore =
538+
JSON.stringify(pStore) === JSON.stringify(sessionStorage)
539+
? localStorage
540+
: sessionStorage;
538541
return (
539542
document.documentElement.dataset.mode ||
540543
pStore.getItem(this.THEME_STORAGE_KEY) ||

0 commit comments

Comments
 (0)