bookish-press 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -48,7 +48,8 @@ onMount(() => {
|
|
|
48
48
|
});
|
|
49
49
|
// Default dark mode to whatever's stored in local storage, if anything.
|
|
50
50
|
// respect user choice on the website despite the system theme
|
|
51
|
-
let darkMode = writable(localStorage
|
|
51
|
+
let darkMode = writable(typeof localStorage !== "undefined" &&
|
|
52
|
+
localStorage.getItem("bookish-dark") !== "false" && (localStorage.getItem("bookish-dark") === "true" || // A previous setting
|
|
52
53
|
window.matchMedia("(prefers-color-scheme: dark)").matches // Operating system is set to dark
|
|
53
54
|
));
|
|
54
55
|
// Expose dark mode to descendants
|
|
@@ -57,11 +58,11 @@ setContext(DARK_MODE, darkMode);
|
|
|
57
58
|
$: {
|
|
58
59
|
if ($darkMode) {
|
|
59
60
|
document.body.classList.add("bookish-dark");
|
|
60
|
-
localStorage.setItem("bookish-dark", "true");
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
63
|
document.body.classList.remove("bookish-dark");
|
|
64
|
-
|
|
64
|
+
if (typeof localStorage !== "undefined")
|
|
65
|
+
localStorage.setItem("bookish-dark", $darkMode ? "true" : "false");
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
// Redirect old hash routes by simply replacing their hash before routing.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<div class={"bookish bookish-loading" + (localStorage.getItem("bookish-dark") === "true" ? " bookish-dark" : "")}>
|
|
1
|
+
<div class={"bookish bookish-loading" + (typeof localStorage !== "undefined" && localStorage.getItem("bookish-dark") === "true" ? " bookish-dark" : "")}>
|
|
2
2
|
<div class="bookish-loading-animation">
|
|
3
3
|
<div></div>
|
|
4
4
|
<div></div>
|
|
@@ -33,7 +33,7 @@ function getProgressDescription(progress) {
|
|
|
33
33
|
return "; done";
|
|
34
34
|
}
|
|
35
35
|
// Get the chapter progress
|
|
36
|
-
let progressStorage = localStorage.getItem("chapterProgress");
|
|
36
|
+
let progressStorage = typeof localStorage !== "undefined" ? localStorage.getItem("chapterProgress") : null;
|
|
37
37
|
let progress = progressStorage === null ?
|
|
38
38
|
{} :
|
|
39
39
|
JSON.parse(progressStorage);
|