@novely/solid-renderer 0.0.5 → 0.0.7

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/dist/index.jsx CHANGED
@@ -122,31 +122,99 @@ var Modal = (props) => {
122
122
  };
123
123
 
124
124
  // ../typewriter/dist/index.js
125
- var b = () => Math.min(90 * Math.random() + 100, 90);
126
- var v = ({ node: N, text: m, ended: c, speed: T = b }) => {
127
- let e = document.createElement("span");
128
- e.innerHTML = m;
129
- let l = (t, M) => {
130
- let d = [];
131
- return t.childNodes.forEach((s) => {
132
- s.nodeName === "#text" && (d.push(s), M && (s.textContent = "")), d.push(...l(s, M));
133
- }), d;
134
- }, u = l(e.cloneNode(true), false).map((t) => [...t.textContent]), q = l(e, true);
135
- N.appendChild(e);
136
- let n = 0, a = 0, r = false, p, i = () => {
137
- p = requestAnimationFrame(x);
138
- }, o = () => {
139
- cancelAnimationFrame(p);
140
- }, f = 0, h = 0, x = (t) => {
141
- t >= h + f ? (h = t, f = T(), C()) : r ? o() : i();
142
- }, C = () => {
143
- u[n]?.length > a ? (q[n].textContent += u[n][a++], i()) : n++ < u.length ? (a = 0, i()) : (r = true, o(), c && c());
125
+ var defaultSpeed = () => {
126
+ return Math.min(90 * Math.random() + 100, 90);
127
+ };
128
+ var collectTextNodes = (el) => {
129
+ const items = [];
130
+ el.childNodes.forEach((child) => {
131
+ if (child.nodeName === "#text")
132
+ items.push(child);
133
+ else
134
+ items.push(...collectTextNodes(child));
135
+ });
136
+ return items;
137
+ };
138
+ var typewriter = ({ node, text, ended, speed = defaultSpeed }) => {
139
+ node.innerHTML = text;
140
+ const nodes = collectTextNodes(node).map((child) => {
141
+ const letters = [...child.textContent].map((char) => {
142
+ const text2 = document.createElement("span");
143
+ text2.textContent = char;
144
+ text2.style.cssText = "opacity: 0;";
145
+ return text2;
146
+ });
147
+ child.replaceWith(...letters);
148
+ return letters;
149
+ });
150
+ let current = 0;
151
+ let pos = 0;
152
+ let end = false;
153
+ let frame;
154
+ const enqueue = () => {
155
+ frame = requestAnimationFrame(queue);
156
+ };
157
+ const dequeue = () => {
158
+ cancelAnimationFrame(frame);
159
+ };
160
+ let timeout = 0;
161
+ let start = 0;
162
+ let container;
163
+ const queue = (time) => {
164
+ if (time >= start + timeout) {
165
+ start = time;
166
+ timeout = speed();
167
+ process();
168
+ } else if (!end) {
169
+ enqueue();
170
+ } else {
171
+ dequeue();
172
+ }
173
+ };
174
+ const process = () => {
175
+ const block = nodes[current];
176
+ if (block?.length > pos) {
177
+ const span = block[pos];
178
+ const text2 = span.textContent;
179
+ if (pos++ === 0) {
180
+ span.replaceWith(container = document.createTextNode(text2));
181
+ } else {
182
+ container.textContent += text2;
183
+ span.remove();
184
+ }
185
+ enqueue();
186
+ } else if (current++ < nodes.length) {
187
+ pos = 0;
188
+ enqueue();
189
+ } else {
190
+ end = true;
191
+ dequeue();
192
+ ended && ended();
193
+ }
194
+ };
195
+ process();
196
+ return {
197
+ /**
198
+ * End
199
+ */
200
+ end() {
201
+ dequeue();
202
+ if (end) {
203
+ node.innerHTML = "";
204
+ return end;
205
+ }
206
+ node.innerHTML = text;
207
+ end = true;
208
+ return false;
209
+ },
210
+ /**
211
+ * Destroy
212
+ */
213
+ destroy() {
214
+ dequeue();
215
+ node.innerHTML = "";
216
+ }
144
217
  };
145
- return C(), { end() {
146
- return o(), r ? (e.remove(), true) : (e.innerHTML = m, r = true, false);
147
- }, destroy() {
148
- o(), e.remove();
149
- } };
150
218
  };
151
219
 
152
220
  // src/screens/game.tsx
@@ -172,7 +240,9 @@ var Game = (props) => {
172
240
  writer?.destroy();
173
241
  if (!element)
174
242
  return;
175
- writer = v({
243
+ if (!text)
244
+ return;
245
+ writer = typewriter({
176
246
  node: element,
177
247
  text,
178
248
  ended() {
@@ -256,6 +326,7 @@ var Game = (props) => {
256
326
  <div class="dialog-panel">
257
327
  <span
258
328
  class="dialog-panel-label"
329
+ data-used={Boolean(props.state.choices.question)}
259
330
  aria-hidden={!props.state.choices.question}
260
331
  >{props.state.choices.question || <>ᅠ</>}</span>
261
332
  <For each={props.state.choices.choices}>{([text, _, active], i) => {
@@ -296,10 +367,7 @@ var Game = (props) => {
296
367
  <button
297
368
  type="button"
298
369
  class="button control-panel__button"
299
- onClick={() => {
300
- data.options.stack.back();
301
- data.options.restore(data.options.stack.value);
302
- }}
370
+ onClick={data.options.back}
303
371
  >{data.t("GoBack")}</button>
304
372
  <button
305
373
  type="button"
@@ -363,7 +431,7 @@ var Saves = (props) => {
363
431
  };
364
432
  return <div class="root saves">
365
433
  <div class="saves__column"><button type="button" class="button saves__button" onClick={() => props.setState("screen", "mainmenu")}>{data.t("GoBack")}</button></div>
366
- <Show3 when={saves()} fallback={data.t("NoSaves")}><ol class="saves__list"><For2 each={saves()}>{(save) => {
434
+ <div class="saves__list-container"><Show3 when={saves()} fallback={data.t("NoSaves")}><ol class="saves__list"><For2 each={saves()}>{(save) => {
367
435
  const [date, type] = save[2];
368
436
  const stringDate = capitalize(new Date(date).toLocaleDateString(language(), { weekday: "long", year: "numeric", month: "long", day: "numeric", hour: "numeric", minute: "numeric", second: "numeric" }));
369
437
  const stringType = data.t(type === "auto" ? "Automatic" : "Manual");
@@ -379,7 +447,7 @@ var Saves = (props) => {
379
447
  </button>
380
448
  <button type="reset" class="button" aria-label={data.t("DeleteASaveFrom") + " " + stringDate} onClick={[removeSave, date]}><span>{data.t("Remove")}</span></button>
381
449
  </li>;
382
- }}</For2></ol></Show3>
450
+ }}</For2></ol></Show3></div>
383
451
  </div>;
384
452
  };
385
453
 
@@ -175,6 +175,7 @@
175
175
  }
176
176
  .saves__button-load {
177
177
  width: 100%;
178
+ touch-action: auto !important;
178
179
  }
179
180
  @media (orientation: portrait) {
180
181
  .saves__button {
@@ -183,9 +184,17 @@
183
184
  }
184
185
 
185
186
  /* src/styles/saves/list/list.css */
186
- .saves__list {
187
+ .saves__list-container {
187
188
  width: 100%;
188
189
  height: 100%;
190
+ display: flex;
191
+ align-items: center;
192
+ justify-content: center;
193
+ overflow: hidden;
194
+ }
195
+ .saves__list {
196
+ width: 100%;
197
+ height: 80%;
189
198
  padding: 0 1em;
190
199
  display: grid;
191
200
  align-content: flex-start;
@@ -195,10 +204,38 @@
195
204
  overflow-y: scroll;
196
205
  margin-block-start: 0;
197
206
  margin-block-end: 0;
207
+ touch-action: auto !important;
208
+ border-radius: var(--saves-list-border-radius, 14px);
209
+ background-color: var(--saves-list-background-color, #ffffff57);
210
+ }
211
+ .saves__list::-webkit-scrollbar {
212
+ width: 14px;
213
+ }
214
+ .saves__list::-webkit-scrollbar-track {
215
+ background-color: #ffe9f3;
216
+ border-radius: 7px;
217
+ }
218
+ .saves__list::-webkit-scrollbar-thumb {
219
+ background-color: #ffc7df;
220
+ border-radius: 7px;
221
+ }
222
+ .saves__list::-webkit-scrollbar-thumb:hover {
223
+ background-color: #ffc6d8;
224
+ }
225
+ .saves__list:hover {
226
+ scrollbar-color: #ffc6d8;
198
227
  }
199
228
  .saves__list-item {
200
229
  display: flex;
201
230
  }
231
+ @media (orientation: portrait) {
232
+ .saves__list {
233
+ height: 100%;
234
+ }
235
+ .saves__list-container {
236
+ margin-top: 1em;
237
+ }
238
+ }
202
239
 
203
240
  /* src/styles/saves/column/column.css */
204
241
  @media (orientation: portrait) {
@@ -357,17 +394,13 @@
357
394
  background-color: var(--novely-dialog-background-color, #f092b4d8);
358
395
  background-position: var(--novely-dialog-background-position, 0 0, 50px 50px);
359
396
  background-size: var(--novely-dialog-background-size, 100px 100px);
360
- display: grid;
361
- grid-template-areas: "pers text" "pers text";
397
+ display: flex;
398
+ flex-wrap: nowrap;
362
399
  padding-bottom: 2.8em;
363
400
  }
364
- .action-dialog-container[data-no-person=true] {
365
- grid-template-areas: "text text" "text text";
366
- }
367
401
  .action-dialog-person {
368
402
  max-height: 25vh;
369
403
  max-width: 25vw;
370
- grid-area: pers;
371
404
  }
372
405
  .action-dialog-name,
373
406
  .action-dialog-content {
@@ -386,10 +419,9 @@
386
419
  box-shadow: 1px 1px 3px #00000042;
387
420
  }
388
421
  .action-dialog-content {
422
+ width: 100%;
389
423
  font-size: 2.2375em;
390
424
  line-height: 1.2;
391
- width: 100%;
392
- grid-area: text;
393
425
  text-shadow:
394
426
  1px 1px 0 black,
395
427
  -1px -1px 0 black,
@@ -398,7 +430,9 @@
398
430
  }
399
431
  .action-dialog-person > canvas,
400
432
  .action-dialog-person > img {
401
- height: 100%;
433
+ max-height: 100%;
434
+ max-width: 100%;
435
+ object-fit: contain;
402
436
  }
403
437
  @media (orientation: portrait) {
404
438
  .action-dialog {
@@ -417,6 +451,18 @@
417
451
  border-radius: 14px 14px 0 0;
418
452
  }
419
453
  }
454
+ @media only screen and (orientation: landscape) and (hover: none) and (pointer: coarse) {
455
+ .action-dialog-content {
456
+ font-size: 1.32em;
457
+ line-height: 1.15;
458
+ }
459
+ }
460
+ @media only screen and (orientation: landscape) and (hover: hover) and (pointer: coarse) {
461
+ .action-dialog-content {
462
+ font-size: 1.32em;
463
+ line-height: 1.15;
464
+ }
465
+ }
420
466
 
421
467
  /* src/styles/action-dialog/index.css */
422
468
 
@@ -441,9 +487,11 @@
441
487
  .dialog-panel {
442
488
  text-align: left;
443
489
  z-index: 21;
444
- width: 100%;
445
- max-width: 40vw;
446
490
  min-height: 40vh;
491
+ min-width: 50vw;
492
+ max-width: 100vw;
493
+ padding-left: 0.25em;
494
+ padding-right: 0.25em;
447
495
  display: flex;
448
496
  flex-direction: column;
449
497
  align-items: stretch;
@@ -452,6 +500,12 @@
452
500
  user-select: none;
453
501
  font-size: 1.2375em;
454
502
  }
503
+ .dialog-panel-label[data-used=true] {
504
+ background: var(--novely-dialog-panel-label-background, #ffe9f3);
505
+ color: var(--novely-dialog-panel-label-color, #000);
506
+ padding: 0.25em 0.5em;
507
+ border-radius: 0.25em;
508
+ }
455
509
  @media (orientation: portrait) {
456
510
  .dialog-panel {
457
511
  max-width: 95vw;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novely/solid-renderer",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"