@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@berlysia/vertical-writing-slide-system",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "vertical-slides": "./cli.js"
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("vertical-rl");
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(42);
10
- const [withAbsoluteFontSize, setWithAbsoluteFontSize] = useState(false);
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
- function gotoNextSlide(forward = true) {
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.2em 1.2em;
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.4em;
63
+ font-size: 1.4rem;
64
64
  font-weight: bold;
65
65
  margin: 0;
66
- margin-block-end: 0.2em;
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: 1em;
72
+ margin-block-end: 1rem;
73
73
  }
74
74
  ul ul,
75
75
  ol ol {
76
- margin-block-end: 1em;
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.5em;
84
+ margin-block-end: 0.5rem;
85
85
  }
86
86
 
87
87
  .wm-toggle {