@novely/solid-renderer 0.5.1 → 0.7.0
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/components/Modal.d.ts +1 -0
- package/dist/components/Typewriter.d.ts +1 -0
- package/dist/index.jsx +29 -16
- package/dist/renderer.d.ts +14 -1
- package/dist/screens/game.d.ts +1 -0
- package/dist/styles/index.css +17 -17
- package/package.json +1 -1
package/dist/index.jsx
CHANGED
|
@@ -108,6 +108,12 @@ var Modal = (props) => {
|
|
|
108
108
|
let modalWindow;
|
|
109
109
|
const handleKeydown = (event) => {
|
|
110
110
|
if (untrack(props.isOpen) && event.key === "Tab") {
|
|
111
|
+
if (!untrack(props.trapFocus)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (!modalWindow) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
111
117
|
const nodes = modalWindow.querySelectorAll("*");
|
|
112
118
|
const tabbable = Array.from(nodes).filter((node) => node.tabIndex >= 0);
|
|
113
119
|
let index = tabbable.indexOf(document.activeElement);
|
|
@@ -308,7 +314,7 @@ var createTypewriter = ({ resolve }) => {
|
|
|
308
314
|
return;
|
|
309
315
|
if (!node)
|
|
310
316
|
return;
|
|
311
|
-
if (PRM.matches) {
|
|
317
|
+
if (PRM.matches || untrack2(() => props.ignore)) {
|
|
312
318
|
node.innerHTML = text;
|
|
313
319
|
bypassed = true;
|
|
314
320
|
setState("done");
|
|
@@ -354,7 +360,7 @@ var createTypewriter = ({ resolve }) => {
|
|
|
354
360
|
// src/screens/game.tsx
|
|
355
361
|
var Game = (props) => {
|
|
356
362
|
const data = useData();
|
|
357
|
-
const { setState, characters, store, renderer } = props;
|
|
363
|
+
const { setState, characters, store, renderer, controls, skipTypewriterWhenGoingBack } = props;
|
|
358
364
|
const background = () => {
|
|
359
365
|
const is = isCSSImage(props.state.background);
|
|
360
366
|
return {
|
|
@@ -467,12 +473,13 @@ var Game = (props) => {
|
|
|
467
473
|
title: DialogWriter.state() === "idle" ? void 0 : data.t(DialogWriter.state() === "processing" ? "CompleteText" : "GoForward")
|
|
468
474
|
}}
|
|
469
475
|
content={props.state.dialog.content}
|
|
476
|
+
ignore={skipTypewriterWhenGoingBack && props.state.dialog.goingBack}
|
|
470
477
|
speed={speed()}
|
|
471
478
|
ended={onWriterEnd(DialogWriter.clear)}
|
|
472
479
|
/></div>
|
|
473
480
|
</div>
|
|
474
481
|
</div>
|
|
475
|
-
<Modal isOpen={() => props.state.choices.visible}><div class="dialog-container">
|
|
482
|
+
<Modal isOpen={() => props.state.choices.visible} trapFocus={() => !props.state.exitPromptShown}><div class="dialog-container">
|
|
476
483
|
<span class="dialog-fix" aria-hidden="true"></span>
|
|
477
484
|
<div class="dialog-panel">
|
|
478
485
|
<span
|
|
@@ -492,7 +499,7 @@ var Game = (props) => {
|
|
|
492
499
|
}}</For>
|
|
493
500
|
</div>
|
|
494
501
|
</div></Modal>
|
|
495
|
-
<Modal isOpen={() => props.state.input.visible}><div class="dialog-container">
|
|
502
|
+
<Modal isOpen={() => props.state.input.visible} trapFocus={() => !props.state.exitPromptShown}><div class="dialog-container">
|
|
496
503
|
<span class="dialog-fix" aria-hidden="true"></span>
|
|
497
504
|
<div class="dialog-panel input-dialog-panel">
|
|
498
505
|
<label for="novely-input" class="input-dialog-label">
|
|
@@ -508,13 +515,11 @@ var Game = (props) => {
|
|
|
508
515
|
>{data.t("Sumbit")}</button>
|
|
509
516
|
</div>
|
|
510
517
|
</div></Modal>
|
|
511
|
-
<Modal isOpen={() => props.state.exitPromptShown}><div class="dialog-container">
|
|
518
|
+
<Modal isOpen={() => props.state.exitPromptShown} trapFocus={() => props.state.exitPromptShown}><div class="dialog-container">
|
|
512
519
|
<span class="dialog-fix" aria-hidden="true"></span>
|
|
513
520
|
<div class="dialog-backdrop" />
|
|
514
521
|
<div class="dialog-panel exit-dialog-panel">
|
|
515
|
-
<span
|
|
516
|
-
class="dialog-panel-label"
|
|
517
|
-
>{data.t("ExitDialogWarning")}</span>
|
|
522
|
+
<span class="dialog-panel-label">{data.t("ExitDialogWarning")}</span>
|
|
518
523
|
<div class="exit-dialog-panel-buttons">
|
|
519
524
|
<button
|
|
520
525
|
type="button"
|
|
@@ -548,13 +553,14 @@ var Game = (props) => {
|
|
|
548
553
|
title: TextWriter.state() === "idle" ? void 0 : data.t(TextWriter.state() === "processing" ? "CompleteText" : "GoForward")
|
|
549
554
|
}}
|
|
550
555
|
content={props.state.text.content}
|
|
556
|
+
ignore={skipTypewriterWhenGoingBack && props.state.text.goingBack}
|
|
551
557
|
speed={speed()}
|
|
552
558
|
ended={onWriterEnd(TextWriter.clear)}
|
|
553
559
|
/></div>
|
|
554
560
|
<div
|
|
555
561
|
class="control-panel"
|
|
556
562
|
classList={{
|
|
557
|
-
"control-panel--center":
|
|
563
|
+
"control-panel--center": controls === "inside"
|
|
558
564
|
}}
|
|
559
565
|
>
|
|
560
566
|
<button
|
|
@@ -764,14 +770,15 @@ var CustomScreen = (props) => {
|
|
|
764
770
|
};
|
|
765
771
|
|
|
766
772
|
// src/renderer.tsx
|
|
767
|
-
var createSolidRenderer = ({ fullscreen = false, controls = "outside" } = {}) => {
|
|
773
|
+
var createSolidRenderer = ({ fullscreen = false, controls = "outside", skipTypewriterWhenGoingBack = true } = {}) => {
|
|
768
774
|
const [state, setState] = createStore({
|
|
769
775
|
background: "",
|
|
770
776
|
characters: {},
|
|
771
777
|
dialog: {
|
|
772
778
|
content: "",
|
|
773
779
|
name: "",
|
|
774
|
-
visible: false
|
|
780
|
+
visible: false,
|
|
781
|
+
goingBack: false
|
|
775
782
|
},
|
|
776
783
|
choices: {
|
|
777
784
|
question: "",
|
|
@@ -784,7 +791,8 @@ var createSolidRenderer = ({ fullscreen = false, controls = "outside" } = {}) =>
|
|
|
784
791
|
visible: false
|
|
785
792
|
},
|
|
786
793
|
text: {
|
|
787
|
-
content: ""
|
|
794
|
+
content: "",
|
|
795
|
+
goingBack: false
|
|
788
796
|
},
|
|
789
797
|
layers: {},
|
|
790
798
|
screens: {},
|
|
@@ -877,14 +885,15 @@ var createSolidRenderer = ({ fullscreen = false, controls = "outside" } = {}) =>
|
|
|
877
885
|
};
|
|
878
886
|
},
|
|
879
887
|
dialog(content, name, character, emotion) {
|
|
880
|
-
return (resolve) => {
|
|
888
|
+
return (resolve, goingBack) => {
|
|
881
889
|
setState("dialog", () => ({
|
|
882
890
|
content,
|
|
883
891
|
name,
|
|
884
892
|
character,
|
|
885
893
|
emotion,
|
|
886
894
|
visible: true,
|
|
887
|
-
resolve
|
|
895
|
+
resolve,
|
|
896
|
+
goingBack
|
|
888
897
|
}));
|
|
889
898
|
};
|
|
890
899
|
},
|
|
@@ -1020,8 +1029,8 @@ var createSolidRenderer = ({ fullscreen = false, controls = "outside" } = {}) =>
|
|
|
1020
1029
|
result ? result.then(resolve) : resolve();
|
|
1021
1030
|
return result;
|
|
1022
1031
|
},
|
|
1023
|
-
text(content, resolve) {
|
|
1024
|
-
setState("text", { content, resolve });
|
|
1032
|
+
text(content, resolve, goingBack) {
|
|
1033
|
+
setState("text", { content, resolve, goingBack });
|
|
1025
1034
|
},
|
|
1026
1035
|
store,
|
|
1027
1036
|
ui: {
|
|
@@ -1071,6 +1080,10 @@ var createSolidRenderer = ({ fullscreen = false, controls = "outside" } = {}) =>
|
|
|
1071
1080
|
/* @once */
|
|
1072
1081
|
controls
|
|
1073
1082
|
}
|
|
1083
|
+
skipTypewriterWhenGoingBack={
|
|
1084
|
+
/* @once */
|
|
1085
|
+
skipTypewriterWhenGoingBack
|
|
1086
|
+
}
|
|
1074
1087
|
/></Match>
|
|
1075
1088
|
<Match when={state.screen === "mainmenu"}><MainMenu state={state} setState={
|
|
1076
1089
|
/* @once */
|
package/dist/renderer.d.ts
CHANGED
|
@@ -35,6 +35,10 @@ interface StateDialog {
|
|
|
35
35
|
* Имя персонажа
|
|
36
36
|
*/
|
|
37
37
|
name: string;
|
|
38
|
+
/**
|
|
39
|
+
* Is goingBack
|
|
40
|
+
*/
|
|
41
|
+
goingBack: boolean;
|
|
38
42
|
/**
|
|
39
43
|
* Функция `resolve`
|
|
40
44
|
*/
|
|
@@ -90,6 +94,10 @@ interface StateText {
|
|
|
90
94
|
* Текст
|
|
91
95
|
*/
|
|
92
96
|
content: string;
|
|
97
|
+
/**
|
|
98
|
+
* Is goingBack
|
|
99
|
+
*/
|
|
100
|
+
goingBack: boolean;
|
|
93
101
|
/**
|
|
94
102
|
* Функция `resolve`
|
|
95
103
|
*/
|
|
@@ -137,8 +145,13 @@ interface CreateSolidRendererOptions {
|
|
|
137
145
|
* @default "outside"
|
|
138
146
|
*/
|
|
139
147
|
controls?: "inside" | "outside";
|
|
148
|
+
/**
|
|
149
|
+
* When `goingBack` typewriter effect won't be applied
|
|
150
|
+
* @default true
|
|
151
|
+
*/
|
|
152
|
+
skipTypewriterWhenGoingBack?: boolean;
|
|
140
153
|
}
|
|
141
|
-
declare const createSolidRenderer: ({ fullscreen, controls }?: CreateSolidRendererOptions) => {
|
|
154
|
+
declare const createSolidRenderer: ({ fullscreen, controls, skipTypewriterWhenGoingBack }?: CreateSolidRendererOptions) => {
|
|
142
155
|
createRenderer(init: RendererInit): Renderer;
|
|
143
156
|
Novely(props: Omit<JSX.HTMLAttributes<HTMLDivElement>, 'children' | 'ref'>): JSX.Element;
|
|
144
157
|
registerScreen(name: string, screen: StateScreen): void;
|
package/dist/screens/game.d.ts
CHANGED
package/dist/styles/index.css
CHANGED
|
@@ -291,7 +291,7 @@
|
|
|
291
291
|
font-size: 1.32rem;
|
|
292
292
|
}
|
|
293
293
|
.action-dialog-container {
|
|
294
|
-
border-radius: 14px 14px 0 0;
|
|
294
|
+
border-radius: var(--novely-dialog-border-radius, 14px 14px 0 0);
|
|
295
295
|
}
|
|
296
296
|
.action-dialog-content {
|
|
297
297
|
text-shadow: none;
|
|
@@ -388,16 +388,16 @@
|
|
|
388
388
|
max-width: 100%;
|
|
389
389
|
}
|
|
390
390
|
.input-dialog-panel {
|
|
391
|
-
color: #fff;
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
background-
|
|
396
|
-
|
|
397
|
-
|
|
391
|
+
color: var(--novely-input-dialog-color, #fff);
|
|
392
|
+
border: var(--novely-input-dialog-border-width, 3px) solid var(--novely-input-dialog-border-color, #fff);
|
|
393
|
+
border-radius: var(--novely-input-dialog-border-radius, 14px);
|
|
394
|
+
box-shadow: 1px 1px 4px var(--novely-input-dialog-box-shadow-color, #00000072);
|
|
395
|
+
background-image: var(--novely-input-dialog-background-image, radial-gradient(#d6608998 20%, transparent 20%), radial-gradient(#d6608998 20%, transparent 20%));
|
|
396
|
+
background-color: var(--novely-input-dialog-background-color, #f092b4d8);
|
|
397
|
+
background-position: var(--novely-input-dialog-background-position, 0 0, 50px 50px);
|
|
398
|
+
background-size: var(--novely-input-dialog-background-size, 100px 100px);
|
|
398
399
|
justify-content: center;
|
|
399
400
|
align-items: center;
|
|
400
|
-
box-shadow: 1px 1px 4px #00000072;
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
/* src/styles/input-dialog/button/button.css */
|
|
@@ -411,16 +411,16 @@
|
|
|
411
411
|
|
|
412
412
|
/* src/styles/exit-dialog/exit-dialog.css */
|
|
413
413
|
.exit-dialog-panel {
|
|
414
|
-
color: #fff;
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
background-
|
|
419
|
-
|
|
420
|
-
|
|
414
|
+
color: var(--novely-exit-dialog-color, #fff);
|
|
415
|
+
border: var(--novely-exit-dialog-border-width, 3px) solid var(--novely-exit-dialog-border-color, #fff);
|
|
416
|
+
border-radius: var(--novely-exit-dialog-border-radius, 14px);
|
|
417
|
+
box-shadow: 1px 1px 4px var(--novely-exit-dialog-box-shadow-color, #00000072);
|
|
418
|
+
background-image: var(--novely-exit-dialog-background-image, radial-gradient(#d6608998 20%, transparent 20%), radial-gradient(#d6608998 20%, transparent 20%));
|
|
419
|
+
background-color: var(--novely-exit-dialog-background-color, #f092b4d8);
|
|
420
|
+
background-position: var(--novely-exit-dialog-background-position, 0 0, 50px 50px);
|
|
421
|
+
background-size: var(--novely-exit-dialog-background-size, 100px 100px);
|
|
421
422
|
justify-content: center;
|
|
422
423
|
align-items: center;
|
|
423
|
-
box-shadow: 1px 1px 4px #00000072;
|
|
424
424
|
}
|
|
425
425
|
.exit-dialog-panel-buttons {
|
|
426
426
|
gap: .5rem;
|