bookish-press 0.4.21 → 0.4.23
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.
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script>import smoothscroll from 'smoothscroll-polyfill';
|
|
2
2
|
import { goto } from '$app/navigation';
|
|
3
|
-
import { setContext } from 'svelte';
|
|
3
|
+
import { onMount, setContext } from 'svelte';
|
|
4
4
|
import { writable } from 'svelte/store';
|
|
5
5
|
import { BASE, DARK_MODE, EDITABLE, } from './Contexts';
|
|
6
6
|
import { BookishTheme } from '../../models/book/Theme';
|
|
7
7
|
// Poly fill smooth scrolling for Safari.
|
|
8
|
-
smoothscroll.polyfill();
|
|
8
|
+
onMount(() => smoothscroll.polyfill());
|
|
9
9
|
// True if the edition should be editable. Distributed as context.
|
|
10
10
|
export let editable = false;
|
|
11
11
|
// When editable changes, update the context.
|
|
@@ -32,12 +32,14 @@ let darkMode = writable(typeof localStorage !== 'undefined' &&
|
|
|
32
32
|
setContext(DARK_MODE, darkMode);
|
|
33
33
|
// When dark mode changes, update the body's class list.
|
|
34
34
|
$: {
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
if (typeof document !== undefined) {
|
|
36
|
+
if ($darkMode)
|
|
37
|
+
document.body.classList.add('dark');
|
|
38
|
+
else
|
|
39
|
+
document.body.classList.remove('dark');
|
|
40
|
+
if (typeof localStorage !== 'undefined')
|
|
41
|
+
localStorage.setItem('dark', $darkMode ? 'true' : 'false');
|
|
42
|
+
}
|
|
41
43
|
}
|
|
42
44
|
// Redirect old hash routes by simply replacing their hash before routing.
|
|
43
45
|
if (typeof window !== 'undefined' && window.location.hash.startsWith('#/'))
|