@novely/solid-renderer 0.0.6 → 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 +96 -29
- package/dist/styles/index.css +6 -9
- package/package.json +1 -1
package/dist/index.jsx
CHANGED
|
@@ -122,31 +122,99 @@ var Modal = (props) => {
|
|
|
122
122
|
};
|
|
123
123
|
|
|
124
124
|
// ../typewriter/dist/index.js
|
|
125
|
-
var
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
|
|
243
|
+
if (!text)
|
|
244
|
+
return;
|
|
245
|
+
writer = typewriter({
|
|
176
246
|
node: element,
|
|
177
247
|
text,
|
|
178
248
|
ended() {
|
|
@@ -297,10 +367,7 @@ var Game = (props) => {
|
|
|
297
367
|
<button
|
|
298
368
|
type="button"
|
|
299
369
|
class="button control-panel__button"
|
|
300
|
-
onClick={
|
|
301
|
-
data.options.stack.back();
|
|
302
|
-
data.options.restore(data.options.stack.value);
|
|
303
|
-
}}
|
|
370
|
+
onClick={data.options.back}
|
|
304
371
|
>{data.t("GoBack")}</button>
|
|
305
372
|
<button
|
|
306
373
|
type="button"
|
package/dist/styles/index.css
CHANGED
|
@@ -394,17 +394,13 @@
|
|
|
394
394
|
background-color: var(--novely-dialog-background-color, #f092b4d8);
|
|
395
395
|
background-position: var(--novely-dialog-background-position, 0 0, 50px 50px);
|
|
396
396
|
background-size: var(--novely-dialog-background-size, 100px 100px);
|
|
397
|
-
display:
|
|
398
|
-
|
|
397
|
+
display: flex;
|
|
398
|
+
flex-wrap: nowrap;
|
|
399
399
|
padding-bottom: 2.8em;
|
|
400
400
|
}
|
|
401
|
-
.action-dialog-container[data-no-person=true] {
|
|
402
|
-
grid-template-areas: "text text" "text text";
|
|
403
|
-
}
|
|
404
401
|
.action-dialog-person {
|
|
405
402
|
max-height: 25vh;
|
|
406
403
|
max-width: 25vw;
|
|
407
|
-
grid-area: pers;
|
|
408
404
|
}
|
|
409
405
|
.action-dialog-name,
|
|
410
406
|
.action-dialog-content {
|
|
@@ -423,10 +419,9 @@
|
|
|
423
419
|
box-shadow: 1px 1px 3px #00000042;
|
|
424
420
|
}
|
|
425
421
|
.action-dialog-content {
|
|
422
|
+
width: 100%;
|
|
426
423
|
font-size: 2.2375em;
|
|
427
424
|
line-height: 1.2;
|
|
428
|
-
width: 100%;
|
|
429
|
-
grid-area: text;
|
|
430
425
|
text-shadow:
|
|
431
426
|
1px 1px 0 black,
|
|
432
427
|
-1px -1px 0 black,
|
|
@@ -435,7 +430,9 @@
|
|
|
435
430
|
}
|
|
436
431
|
.action-dialog-person > canvas,
|
|
437
432
|
.action-dialog-person > img {
|
|
438
|
-
height: 100%;
|
|
433
|
+
max-height: 100%;
|
|
434
|
+
max-width: 100%;
|
|
435
|
+
object-fit: contain;
|
|
439
436
|
}
|
|
440
437
|
@media (orientation: portrait) {
|
|
441
438
|
.action-dialog {
|