@berlysia/vertical-writing-slide-system 0.0.18 → 0.0.19
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.
- package/package.json +1 -1
- package/src/App.tsx +31 -6
- package/src/index.css +6 -6
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -1,13 +1,38 @@
|
|
|
1
|
-
import { useState, useRef, useEffect } from "react";
|
|
1
|
+
import { useState, useRef, useEffect, useCallback } from "react";
|
|
2
2
|
import slidesContent from "virtual:slides.js";
|
|
3
3
|
|
|
4
4
|
function App() {
|
|
5
|
-
const [writingMode, setWritingMode] = useState(
|
|
5
|
+
const [writingMode, setWritingMode] = useState(() => {
|
|
6
|
+
const saved = sessionStorage.getItem("slide-writing-mode");
|
|
7
|
+
return saved ?? "vertical-rl";
|
|
8
|
+
});
|
|
6
9
|
const isVertical = writingMode !== "horizontal-tb";
|
|
7
10
|
const slidesRef = useRef<HTMLDivElement>(null);
|
|
8
11
|
|
|
9
|
-
const [fontSize, setFontSize] = useState(
|
|
10
|
-
|
|
12
|
+
const [fontSize, setFontSize] = useState(() => {
|
|
13
|
+
const saved = sessionStorage.getItem("slide-font-size");
|
|
14
|
+
return saved ? Number(saved) : 42;
|
|
15
|
+
});
|
|
16
|
+
const [withAbsoluteFontSize, setWithAbsoluteFontSize] = useState(() => {
|
|
17
|
+
const saved = sessionStorage.getItem("slide-with-absolute-font-size");
|
|
18
|
+
return saved === "true";
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// 状態変更時にsessionStorageに保存
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
sessionStorage.setItem("slide-writing-mode", writingMode);
|
|
24
|
+
}, [writingMode]);
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
sessionStorage.setItem("slide-font-size", fontSize.toString());
|
|
28
|
+
}, [fontSize]);
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
sessionStorage.setItem(
|
|
32
|
+
"slide-with-absolute-font-size",
|
|
33
|
+
withAbsoluteFontSize.toString(),
|
|
34
|
+
);
|
|
35
|
+
}, [withAbsoluteFontSize]);
|
|
11
36
|
|
|
12
37
|
// ロード時にハッシュが入ってたらそのページにスクロール
|
|
13
38
|
useEffect(() => {
|
|
@@ -44,7 +69,7 @@ function App() {
|
|
|
44
69
|
};
|
|
45
70
|
}, []);
|
|
46
71
|
|
|
47
|
-
|
|
72
|
+
const gotoNextSlide = useCallback((forward = true) => {
|
|
48
73
|
const currentHash = location.hash;
|
|
49
74
|
const currentIndex = parseInt(currentHash.replace("#page-", ""));
|
|
50
75
|
const nextIndex = forward ? currentIndex + 1 : currentIndex - 1;
|
|
@@ -52,7 +77,7 @@ function App() {
|
|
|
52
77
|
return;
|
|
53
78
|
}
|
|
54
79
|
location.hash = `#page-${nextIndex}`;
|
|
55
|
-
}
|
|
80
|
+
}, []);
|
|
56
81
|
|
|
57
82
|
// keydownイベントでページ送り
|
|
58
83
|
useEffect(() => {
|
package/src/index.css
CHANGED
|
@@ -40,7 +40,7 @@ code {
|
|
|
40
40
|
.wrapper {
|
|
41
41
|
width: 100%;
|
|
42
42
|
height: 100%;
|
|
43
|
-
padding: 1.
|
|
43
|
+
padding: 1.2rem 1.2rem;
|
|
44
44
|
|
|
45
45
|
position: relative;
|
|
46
46
|
|
|
@@ -60,20 +60,20 @@ code {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
h1 {
|
|
63
|
-
font-size: 1.
|
|
63
|
+
font-size: 1.4rem;
|
|
64
64
|
font-weight: bold;
|
|
65
65
|
margin: 0;
|
|
66
|
-
margin-block-end: 0.
|
|
66
|
+
margin-block-end: 0.2rem;
|
|
67
67
|
}
|
|
68
68
|
ul,
|
|
69
69
|
ol {
|
|
70
70
|
list-style-position: outside;
|
|
71
71
|
margin: 0;
|
|
72
|
-
margin-block-end:
|
|
72
|
+
margin-block-end: 1rem;
|
|
73
73
|
}
|
|
74
74
|
ul ul,
|
|
75
75
|
ol ol {
|
|
76
|
-
margin-block-end:
|
|
76
|
+
margin-block-end: 1rem;
|
|
77
77
|
}
|
|
78
78
|
ul ul ul,
|
|
79
79
|
ol ol ol {
|
|
@@ -81,7 +81,7 @@ code {
|
|
|
81
81
|
}
|
|
82
82
|
p {
|
|
83
83
|
margin: 0;
|
|
84
|
-
margin-block-end: 0.
|
|
84
|
+
margin-block-end: 0.5rem;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
.wm-toggle {
|