fossbook 0.0.16 → 0.0.17

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": "fossbook",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "A lightweight static blog site generator for GitHub Pages",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -49,6 +49,64 @@
49
49
  width: var(--dialogue-width, 100%);
50
50
  }
51
51
 
52
+ .transcript-control {
53
+ display: flex;
54
+ justify-content: flex-end;
55
+ margin: .75rem 0 1.5rem;
56
+ }
57
+
58
+ .transcript-toggle {
59
+ align-items: center;
60
+ display: inline-flex;
61
+ font-size: .85rem;
62
+ gap: .65rem;
63
+ }
64
+
65
+ .transcript-toggle label {
66
+ cursor: pointer;
67
+ }
68
+
69
+ .transcript-toggle input {
70
+ appearance: none;
71
+ background: #d8dce2;
72
+ border: 1px solid var(--bordercl);
73
+ border-radius: 999px;
74
+ cursor: pointer;
75
+ height: 1.35rem;
76
+ margin: 0;
77
+ position: relative;
78
+ width: 2.5rem;
79
+ }
80
+
81
+ .transcript-toggle input::before {
82
+ background: #fff;
83
+ border-radius: 50%;
84
+ content: "";
85
+ height: .95rem;
86
+ left: .15rem;
87
+ position: absolute;
88
+ top: .15rem;
89
+ transition: transform 160ms ease;
90
+ width: .95rem;
91
+ }
92
+
93
+ .transcript-toggle input:checked {
94
+ background: var(--maincolor);
95
+ }
96
+
97
+ .transcript-toggle input:checked::before {
98
+ transform: translateX(1.1rem);
99
+ }
100
+
101
+ .transcript-toggle input:focus-visible {
102
+ outline: 2px solid var(--hovercolor);
103
+ outline-offset: 2px;
104
+ }
105
+
106
+ .transcripts-hidden .image-dialogue {
107
+ display: none;
108
+ }
109
+
52
110
 
53
111
  blockquote {
54
112
  margin: 0;
@@ -58,6 +116,16 @@
58
116
  font-style: normal;
59
117
  font-size: 1rem;
60
118
  }
119
+
120
+ @media print {
121
+ .transcript-control {
122
+ display: none;
123
+ }
124
+
125
+ .transcripts-hidden .image-dialogue {
126
+ display: flex;
127
+ }
128
+ }
61
129
 
62
130
  a {
63
131
  border-bottom: 3px solid var(--maincolor);
@@ -25,6 +25,13 @@
25
25
  )}
26
26
 
27
27
  ${page.twitterCard("summary")}
28
+ ${page.body.includes('class="blockquote-container image-dialogue"') ? `<script>
29
+ try {
30
+ if (localStorage.getItem("fossbook-comic-transcript") === "hidden") {
31
+ document.documentElement.classList.add("transcripts-hidden");
32
+ }
33
+ } catch (error) {}
34
+ </script>` : ""}
28
35
  </head>
29
36
  <body>
30
37
  <div class="content">
@@ -45,7 +52,13 @@
45
52
  <h1 class="title">${page.title}</h1>
46
53
  <div class="meta">Posted on ${page.formatDate(new Date(page.date))}</div>
47
54
  </div>
48
- <section class="body">
55
+ ${page.body.includes('class="blockquote-container image-dialogue"') ? `<div class="transcript-control">
56
+ <div class="transcript-toggle">
57
+ <label for="comic-transcript-toggle">Comic transcript</label>
58
+ <input id="comic-transcript-toggle" type="checkbox" role="switch" aria-controls="comic-transcript" checked>
59
+ </div>
60
+ </div>` : ""}
61
+ <section class="body" id="comic-transcript">
49
62
  ${page.body}
50
63
  </section>
51
64
  <div class="post-tags">
@@ -84,6 +97,21 @@
84
97
  mermaid.initialize({ startOnLoad: true });
85
98
  </script>` : ""}
86
99
  ${page.body.includes('class="blockquote-container image-dialogue"') ? `<script>
100
+ const transcriptToggle = document.querySelector("#comic-transcript-toggle");
101
+ const transcriptStorageKey = "fossbook-comic-transcript";
102
+ const setTranscriptVisibility = (visible) => {
103
+ document.documentElement.classList.toggle("transcripts-hidden", !visible);
104
+ transcriptToggle.checked = visible;
105
+ };
106
+ setTranscriptVisibility(!document.documentElement.classList.contains("transcripts-hidden"));
107
+ transcriptToggle.addEventListener("change", () => {
108
+ const visible = transcriptToggle.checked;
109
+ setTranscriptVisibility(visible);
110
+ try {
111
+ localStorage.setItem(transcriptStorageKey, visible ? "visible" : "hidden");
112
+ } catch (error) {}
113
+ });
114
+
87
115
  document.querySelectorAll(".image-container + .image-dialogue").forEach((dialogue) => {
88
116
  const image = dialogue.previousElementSibling.querySelector("img");
89
117
  const syncDialogueWidth = () => {