@olenbetong/synergi-course 2.0.0 → 2.2.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/es/chrome/CategoryHeader.css +28 -0
- package/es/completion/CourseCompletion.css +53 -0
- package/es/completion/CourseCompletion.d.ts +32 -0
- package/es/completion/CourseCompletion.js +60 -0
- package/es/document/cues.d.ts +51 -6
- package/es/document/cues.js +117 -14
- package/es/document/effects.d.ts +30 -0
- package/es/document/effects.js +76 -0
- package/es/document/schema.d.ts +2722 -346
- package/es/document/schema.js +172 -5
- package/es/document/validate.d.ts +2 -1
- package/es/document/validate.js +83 -16
- package/es/index.d.ts +8 -3
- package/es/index.js +6 -2
- package/es/media/Media.css +16 -0
- package/es/media/icons.d.ts +1 -0
- package/es/media/icons.js +3 -0
- package/es/player/CoursePlayer.css +76 -0
- package/es/player/CoursePlayer.js +28 -13
- package/es/player/PlayerBars.d.ts +32 -0
- package/es/player/PlayerBars.js +14 -0
- package/es/player/useFullScreen.d.ts +17 -0
- package/es/player/useFullScreen.js +83 -0
- package/es/player/useMediaQuery.d.ts +7 -0
- package/es/player/useMediaQuery.js +16 -0
- package/es/steps/Blocks.d.ts +43 -3
- package/es/steps/Blocks.js +114 -26
- package/es/steps/Markdown.d.ts +7 -1
- package/es/steps/Markdown.js +31 -4
- package/es/steps/QuizStepView.d.ts +2 -1
- package/es/steps/QuizStepView.js +20 -10
- package/es/steps/RevealMotion.d.ts +29 -0
- package/es/steps/RevealMotion.js +55 -0
- package/es/steps/SlideStepView.d.ts +5 -3
- package/es/steps/SlideStepView.js +43 -10
- package/es/steps/StepBodyProps.d.ts +16 -1
- package/es/steps/StepView.css +390 -16
- package/es/steps/StepView.d.ts +36 -4
- package/es/steps/StepView.js +21 -5
- package/es/steps/motion.d.ts +59 -0
- package/es/steps/motion.js +136 -0
- package/es/transitions/Transitions.css +114 -0
- package/es/transitions/plan.d.ts +66 -0
- package/es/transitions/plan.js +185 -0
- package/es/transitions/playStepTransition.d.ts +23 -0
- package/es/transitions/playStepTransition.js +131 -0
- package/es/types.d.ts +16 -3
- package/package.json +4 -4
- package/src/chrome/CategoryHeader.css +28 -0
- package/src/completion/CourseCompletion.css +53 -0
- package/src/completion/CourseCompletion.test.tsx +45 -0
- package/src/completion/CourseCompletion.tsx +98 -0
- package/src/document/box.test.ts +234 -0
- package/src/document/cues.ts +143 -13
- package/src/document/document.test.ts +1 -1
- package/src/document/effects.ts +106 -0
- package/src/document/reveal.test.ts +263 -0
- package/src/document/schema.ts +203 -5
- package/src/document/validate.ts +88 -18
- package/src/index.ts +46 -1
- package/src/media/Media.css +16 -0
- package/src/media/icons.tsx +8 -0
- package/src/player/CoursePlayer.css +76 -0
- package/src/player/CoursePlayer.test.tsx +70 -6
- package/src/player/CoursePlayer.tsx +91 -60
- package/src/player/PlayerBars.tsx +106 -0
- package/src/player/fullScreen.test.tsx +70 -0
- package/src/player/useFullScreen.ts +91 -0
- package/src/player/useMediaQuery.ts +21 -0
- package/src/steps/Blocks.test.ts +34 -0
- package/src/steps/Blocks.tsx +219 -32
- package/src/steps/Box.test.tsx +95 -0
- package/src/steps/Markdown.test.tsx +46 -0
- package/src/steps/Markdown.tsx +42 -4
- package/src/steps/Presence.test.tsx +82 -0
- package/src/steps/QuizStepView.test.tsx +79 -0
- package/src/steps/QuizStepView.tsx +34 -12
- package/src/steps/RevealMotion.ts +66 -0
- package/src/steps/SlideStepView.tsx +74 -12
- package/src/steps/StepBodyProps.ts +16 -1
- package/src/steps/StepView.css +390 -16
- package/src/steps/StepView.test.tsx +157 -0
- package/src/steps/StepView.tsx +108 -19
- package/src/steps/motion.test.ts +98 -0
- package/src/steps/motion.ts +178 -0
- package/src/steps/visibility.test.ts +24 -0
- package/src/transitions/Transitions.css +114 -0
- package/src/transitions/plan.ts +258 -0
- package/src/transitions/playStepTransition.ts +162 -0
- package/src/transitions/transitions.test.ts +274 -0
- package/src/types.ts +16 -3
- package/es/Transitions.css +0 -55
- package/es/Transitions.d.ts +0 -10
- package/es/Transitions.js +0 -24
- package/src/Transitions.css +0 -55
- package/src/Transitions.ts +0 -35
package/src/document/schema.ts
CHANGED
|
@@ -9,14 +9,17 @@ import {
|
|
|
9
9
|
boolean,
|
|
10
10
|
type InferOutput,
|
|
11
11
|
literal,
|
|
12
|
+
maxValue,
|
|
12
13
|
minLength,
|
|
13
14
|
minValue,
|
|
14
15
|
number,
|
|
15
16
|
optional,
|
|
16
17
|
picklist,
|
|
17
18
|
pipe,
|
|
19
|
+
regex,
|
|
18
20
|
strictObject,
|
|
19
21
|
string,
|
|
22
|
+
union,
|
|
20
23
|
variant,
|
|
21
24
|
} from "valibot";
|
|
22
25
|
|
|
@@ -34,6 +37,18 @@ let source = pipe(string(), minLength(1));
|
|
|
34
37
|
|
|
35
38
|
let seconds = pipe(number(), minValue(0));
|
|
36
39
|
|
|
40
|
+
/** The colour scales a box, a callout or a framed canvas text can take. `brand` is the company theme's own. */
|
|
41
|
+
export const TONES = ["neutral", "info", "success", "warning", "danger", "brand"] as const;
|
|
42
|
+
|
|
43
|
+
/** The colour of a surface. Default `neutral`. */
|
|
44
|
+
let tone = optional(picklist(TONES));
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* `bordered` (the default): a tinted surface with a frame and a coloured edge. `filled`: a solid
|
|
48
|
+
* surface in the tone's colour, with the text in its contrast colour.
|
|
49
|
+
*/
|
|
50
|
+
let surfaceVariant = optional(picklist(["bordered", "filled"]));
|
|
51
|
+
|
|
37
52
|
/**
|
|
38
53
|
* A stretch of narration or video: what is said, and when. The text is also the subtitle. A cue
|
|
39
54
|
* without text is a marker: something on the slide can show or go away at it, but no subtitle is
|
|
@@ -73,18 +88,43 @@ export const narrationSchema = strictObject({
|
|
|
73
88
|
* When a block shows. Without any of these it is there from the start.
|
|
74
89
|
* `reveal: "step"` shows it on the next press of Next, in document order. `revealAt` shows it
|
|
75
90
|
* when the cue with that id starts. `hideAt` removes it again when that cue starts.
|
|
91
|
+
*
|
|
92
|
+
* A part waiting to be shown keeps its place, so the slide does not jump when it comes. A part
|
|
93
|
+
* that also has `hideAt` is a passing one and takes no place before it shows or after it has
|
|
94
|
+
* gone, so parts that follow each other in time (one scene per stretch of the narration) stand
|
|
95
|
+
* in the same spot.
|
|
96
|
+
*
|
|
97
|
+
* `reveal: "with-previous"` is not a press of its own: the part shows when the nearest part above
|
|
98
|
+
* it (in document order) that waits to be shown does, by Next or by its cue. Without such a part
|
|
99
|
+
* it is there from the start. `delay` shows a waiting part that many milliseconds after it is due.
|
|
76
100
|
*/
|
|
77
101
|
let timing = {
|
|
78
|
-
reveal: optional(
|
|
102
|
+
reveal: optional(picklist(["step", "with-previous"])),
|
|
79
103
|
revealAt: optional(id),
|
|
80
104
|
hideAt: optional(id),
|
|
105
|
+
delay: optional(pipe(number(), minValue(0), maxValue(5000))),
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
let milliseconds = {
|
|
109
|
+
/** Milliseconds before it starts, 0 to 5000. */
|
|
110
|
+
delay: optional(pipe(number(), minValue(0), maxValue(5000))),
|
|
111
|
+
/** Milliseconds it takes, 50 to 3000. Default 300. */
|
|
112
|
+
duration: optional(pipe(number(), minValue(50), maxValue(3000))),
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/** How a heading or text is dressed: `caps` writes it in capitals, `shadow` gives the letters a shadow, for words on a picture. */
|
|
116
|
+
let look = {
|
|
117
|
+
caps: optional(boolean()),
|
|
118
|
+
shadow: optional(boolean()),
|
|
81
119
|
};
|
|
82
120
|
|
|
83
121
|
export const headingBlockSchema = strictObject({
|
|
84
122
|
id,
|
|
85
123
|
type: literal("heading"),
|
|
124
|
+
/** One line of Markdown. */
|
|
86
125
|
text,
|
|
87
126
|
level: optional(picklist([1, 2, 3])),
|
|
127
|
+
...look,
|
|
88
128
|
...timing,
|
|
89
129
|
});
|
|
90
130
|
|
|
@@ -93,12 +133,15 @@ export const textBlockSchema = strictObject({
|
|
|
93
133
|
type: literal("text"),
|
|
94
134
|
/** Markdown. */
|
|
95
135
|
text,
|
|
136
|
+
...look,
|
|
96
137
|
...timing,
|
|
97
138
|
});
|
|
98
139
|
|
|
99
140
|
export const listItemSchema = strictObject({
|
|
100
141
|
id,
|
|
101
142
|
text,
|
|
143
|
+
/** A point under the point above it: 1 for a sub-point, 2 for a point under a sub-point. */
|
|
144
|
+
indent: optional(picklist([1, 2])),
|
|
102
145
|
...timing,
|
|
103
146
|
});
|
|
104
147
|
|
|
@@ -136,7 +179,8 @@ export const calloutBlockSchema = strictObject({
|
|
|
136
179
|
/** Markdown. */
|
|
137
180
|
text,
|
|
138
181
|
/** The colour of the box. Default `neutral`. */
|
|
139
|
-
tone
|
|
182
|
+
tone,
|
|
183
|
+
variant: surfaceVariant,
|
|
140
184
|
...timing,
|
|
141
185
|
});
|
|
142
186
|
|
|
@@ -149,6 +193,49 @@ export const videoLinkBlockSchema = strictObject({
|
|
|
149
193
|
...timing,
|
|
150
194
|
});
|
|
151
195
|
|
|
196
|
+
/**
|
|
197
|
+
* A block that shows nothing and acts on other parts while it is shown (by its timing, like any
|
|
198
|
+
* part): it moves, scales or fades its targets, and they go back when it stops. `move` is in the
|
|
199
|
+
* slide's text size (1 is about the height of a letter of the ordinary text), or for an item on a
|
|
200
|
+
* canvas in percent of the canvas's width (`x`) and height (`y`). Several effects on one part
|
|
201
|
+
* combine: moves add up, scales multiply, and the last opacity in the document wins.
|
|
202
|
+
*/
|
|
203
|
+
export const effectBlockSchema = strictObject({
|
|
204
|
+
id,
|
|
205
|
+
type: literal("effect"),
|
|
206
|
+
/** The id of a part of the slide, or several. Not an effect. */
|
|
207
|
+
target: union([id, pipe(array(id), minLength(1))]),
|
|
208
|
+
move: optional(strictObject({ x: optional(number()), y: optional(number()) })),
|
|
209
|
+
scale: optional(pipe(number(), minValue(0))),
|
|
210
|
+
opacity: optional(pipe(number(), minValue(0), maxValue(1))),
|
|
211
|
+
...timing,
|
|
212
|
+
/** Milliseconds the change takes, 50 to 3000. Default 300. `delay` holds it back after it is due. */
|
|
213
|
+
duration: milliseconds.duration,
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
/** Every block that can stand inside a box. A box holds no box, callout, columns or canvas. */
|
|
217
|
+
export const boxContentSchema = variant("type", [
|
|
218
|
+
headingBlockSchema,
|
|
219
|
+
textBlockSchema,
|
|
220
|
+
listBlockSchema,
|
|
221
|
+
imageBlockSchema,
|
|
222
|
+
quoteBlockSchema,
|
|
223
|
+
videoLinkBlockSchema,
|
|
224
|
+
effectBlockSchema,
|
|
225
|
+
]);
|
|
226
|
+
|
|
227
|
+
/** A coloured box around other blocks, e.g. a heading and a list of steps. */
|
|
228
|
+
export const boxBlockSchema = strictObject({
|
|
229
|
+
id,
|
|
230
|
+
type: literal("box"),
|
|
231
|
+
/** The colour of the box. Default `neutral`. */
|
|
232
|
+
tone,
|
|
233
|
+
variant: surfaceVariant,
|
|
234
|
+
/** Headings, texts, lists, images, quotes and video links, and effects. No box, callout, columns or canvas. */
|
|
235
|
+
blocks: array(boxContentSchema),
|
|
236
|
+
...timing,
|
|
237
|
+
});
|
|
238
|
+
|
|
152
239
|
/** Every block that can stand inside a column. Columns do not nest. */
|
|
153
240
|
export const contentBlockSchema = variant("type", [
|
|
154
241
|
headingBlockSchema,
|
|
@@ -157,7 +244,9 @@ export const contentBlockSchema = variant("type", [
|
|
|
157
244
|
imageBlockSchema,
|
|
158
245
|
quoteBlockSchema,
|
|
159
246
|
calloutBlockSchema,
|
|
247
|
+
boxBlockSchema,
|
|
160
248
|
videoLinkBlockSchema,
|
|
249
|
+
effectBlockSchema,
|
|
161
250
|
]);
|
|
162
251
|
|
|
163
252
|
export const columnSchema = strictObject({
|
|
@@ -172,6 +261,59 @@ export const columnsBlockSchema = strictObject({
|
|
|
172
261
|
...timing,
|
|
173
262
|
});
|
|
174
263
|
|
|
264
|
+
/**
|
|
265
|
+
* Where an item stands on its canvas, in percent of the canvas: `x` from the left edge or `right`
|
|
266
|
+
* from the right one, `y` from the top or `bottom` from the bottom. Without a width a text is as
|
|
267
|
+
* wide as its words and an image keeps its proportions.
|
|
268
|
+
*/
|
|
269
|
+
let canvasPlace = {
|
|
270
|
+
x: optional(number()),
|
|
271
|
+
y: optional(number()),
|
|
272
|
+
right: optional(number()),
|
|
273
|
+
bottom: optional(number()),
|
|
274
|
+
width: optional(number()),
|
|
275
|
+
height: optional(number()),
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
export const canvasTextSchema = strictObject({
|
|
279
|
+
id,
|
|
280
|
+
type: literal("text"),
|
|
281
|
+
/** Markdown. */
|
|
282
|
+
text,
|
|
283
|
+
/** `solid`: on a white surface that covers what is under it. `frame`: the same with a coloured frame. */
|
|
284
|
+
surface: optional(picklist(["none", "solid", "frame"])),
|
|
285
|
+
/** The colour of the frame. Default `neutral`. */
|
|
286
|
+
tone,
|
|
287
|
+
/** The text size, as a factor of the canvas's normal size. Default 1. */
|
|
288
|
+
size: optional(pipe(number(), minValue(0.1))),
|
|
289
|
+
...canvasPlace,
|
|
290
|
+
...timing,
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
export const canvasImageSchema = strictObject({
|
|
294
|
+
id,
|
|
295
|
+
type: literal("image"),
|
|
296
|
+
src: source,
|
|
297
|
+
alt: optional(text),
|
|
298
|
+
...canvasPlace,
|
|
299
|
+
...timing,
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* A figure with a coordinate system of its own: images and texts placed by percent on an area of
|
|
304
|
+
* fixed proportions, later items on top of earlier ones. Everything scales with the canvas, the
|
|
305
|
+
* text included, so the parts keep their places at any size. Always light, like a sheet of paper,
|
|
306
|
+
* so a surface can cover a part of a picture. Does not stand in a column.
|
|
307
|
+
*/
|
|
308
|
+
export const canvasBlockSchema = strictObject({
|
|
309
|
+
id,
|
|
310
|
+
type: literal("canvas"),
|
|
311
|
+
/** Width to height, e.g. `16/9` (the default) or `4/3`. */
|
|
312
|
+
aspect: optional(pipe(string(), regex(/^\d+(\.\d+)?\s*\/\s*\d+(\.\d+)?$/))),
|
|
313
|
+
items: array(variant("type", [canvasTextSchema, canvasImageSchema])),
|
|
314
|
+
...timing,
|
|
315
|
+
});
|
|
316
|
+
|
|
175
317
|
export const blockSchema = variant("type", [
|
|
176
318
|
headingBlockSchema,
|
|
177
319
|
textBlockSchema,
|
|
@@ -179,8 +321,11 @@ export const blockSchema = variant("type", [
|
|
|
179
321
|
imageBlockSchema,
|
|
180
322
|
quoteBlockSchema,
|
|
181
323
|
calloutBlockSchema,
|
|
324
|
+
boxBlockSchema,
|
|
182
325
|
videoLinkBlockSchema,
|
|
326
|
+
effectBlockSchema,
|
|
183
327
|
columnsBlockSchema,
|
|
328
|
+
canvasBlockSchema,
|
|
184
329
|
]);
|
|
185
330
|
|
|
186
331
|
let version = literal(STEP_SCHEMA_VERSION);
|
|
@@ -191,16 +336,52 @@ let version = literal(STEP_SCHEMA_VERSION);
|
|
|
191
336
|
*/
|
|
192
337
|
let advance = optional(literal("auto"));
|
|
193
338
|
|
|
339
|
+
/**
|
|
340
|
+
* One animation of a step change. `on: "enter"` runs as the step comes in, `on: "exit"` as it
|
|
341
|
+
* leaves. `target` is `step` (the default: the whole step box), `content` or `background` (a
|
|
342
|
+
* slide's blocks or its background image) or the id of a part of the step. `slide` comes from
|
|
343
|
+
* (or leaves to) `from`: right on enter and left on exit by default, mirrored when the learner
|
|
344
|
+
* goes back. Several items on one target run together, each with its own delay and duration.
|
|
345
|
+
*/
|
|
346
|
+
export const transitionSchema = strictObject({
|
|
347
|
+
on: picklist(["enter", "exit"]),
|
|
348
|
+
effect: picklist(["fade", "slide", "zoom", "none"]),
|
|
349
|
+
from: optional(picklist(["left", "right", "top", "bottom"])),
|
|
350
|
+
target: optional(pipe(string(), minLength(1))),
|
|
351
|
+
...milliseconds,
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Left out, the step fades out and the next fades in. Given, it replaces that default on both
|
|
356
|
+
* sides: only what is listed animates, and an empty list changes the step at once.
|
|
357
|
+
*/
|
|
358
|
+
let transitions = optional(array(transitionSchema));
|
|
359
|
+
|
|
194
360
|
/** Blocks on a page, optionally narrated. */
|
|
195
361
|
export const slideStepSchema = strictObject({
|
|
196
362
|
schemaVersion: version,
|
|
197
363
|
type: literal("slide"),
|
|
198
|
-
/**
|
|
199
|
-
|
|
364
|
+
/**
|
|
365
|
+
* `title`: a title page, the first heading large and centred, typically over a background image.
|
|
366
|
+
* `banner`: a title page whose background image is a band across the step, in its own
|
|
367
|
+
* proportions and with a coloured border above and below, with the blocks on top of it.
|
|
368
|
+
*/
|
|
369
|
+
layout: optional(picklist(["default", "centered", "title", "banner"])),
|
|
200
370
|
/** A background image behind the blocks. */
|
|
201
371
|
background: optional(source),
|
|
372
|
+
/**
|
|
373
|
+
* How wide the blocks may get: `narrow` for a few lines or a single callout, `medium`, or
|
|
374
|
+
* `wide`, the default. The slide is never wider than the step it is shown in.
|
|
375
|
+
*/
|
|
376
|
+
width: optional(picklist(["narrow", "medium", "wide"])),
|
|
377
|
+
/**
|
|
378
|
+
* Over a background image the blocks sit on a panel so they stay readable. `false` leaves the
|
|
379
|
+
* panel out, for blocks that bring a surface of their own (callouts). No effect without a background.
|
|
380
|
+
*/
|
|
381
|
+
panel: optional(boolean()),
|
|
202
382
|
narration: optional(narrationSchema),
|
|
203
383
|
advance,
|
|
384
|
+
transitions,
|
|
204
385
|
blocks: array(blockSchema),
|
|
205
386
|
});
|
|
206
387
|
|
|
@@ -213,6 +394,7 @@ export const videoStepSchema = strictObject({
|
|
|
213
394
|
/** An image shown behind and around the video. */
|
|
214
395
|
background: optional(source),
|
|
215
396
|
advance,
|
|
397
|
+
transitions,
|
|
216
398
|
});
|
|
217
399
|
|
|
218
400
|
/** A document the learner opens and then confirms having read. */
|
|
@@ -225,6 +407,7 @@ export const pdfStepSchema = strictObject({
|
|
|
225
407
|
file: source,
|
|
226
408
|
/** The wording of the confirmation, e.g. "Jeg har lest og forstått". */
|
|
227
409
|
confirm: text,
|
|
410
|
+
transitions,
|
|
228
411
|
});
|
|
229
412
|
|
|
230
413
|
/**
|
|
@@ -239,18 +422,27 @@ export const quizStepSchema = strictObject({
|
|
|
239
422
|
text: optional(text),
|
|
240
423
|
/** Plays on the intro, before the quiz is started. Never holds the quiz back. */
|
|
241
424
|
narration: optional(narrationSchema),
|
|
425
|
+
transitions,
|
|
242
426
|
});
|
|
243
427
|
|
|
244
428
|
export const stepSchema = variant("type", [slideStepSchema, videoStepSchema, pdfStepSchema, quizStepSchema]);
|
|
245
429
|
|
|
246
430
|
export type Cue = InferOutput<typeof cueSchema>;
|
|
431
|
+
export type StepTransition = InferOutput<typeof transitionSchema>;
|
|
247
432
|
export type Media = InferOutput<typeof mediaSchema>;
|
|
248
433
|
export type Narration = InferOutput<typeof narrationSchema>;
|
|
434
|
+
export type Tone = (typeof TONES)[number];
|
|
435
|
+
export type SurfaceVariant = NonNullable<InferOutput<typeof calloutBlockSchema>["variant"]>;
|
|
249
436
|
export type CalloutBlock = InferOutput<typeof calloutBlockSchema>;
|
|
437
|
+
export type BoxBlock = InferOutput<typeof boxBlockSchema>;
|
|
438
|
+
export type BoxContentBlock = InferOutput<typeof boxContentSchema>;
|
|
439
|
+
export type EffectBlock = InferOutput<typeof effectBlockSchema>;
|
|
250
440
|
export type ImageSize = NonNullable<InferOutput<typeof imageBlockSchema>["size"]>;
|
|
251
441
|
export type ListItem = InferOutput<typeof listItemSchema>;
|
|
252
442
|
export type ContentBlock = InferOutput<typeof contentBlockSchema>;
|
|
253
443
|
export type ColumnsBlock = InferOutput<typeof columnsBlockSchema>;
|
|
444
|
+
export type CanvasBlock = InferOutput<typeof canvasBlockSchema>;
|
|
445
|
+
export type CanvasItem = CanvasBlock["items"][number];
|
|
254
446
|
export type Block = InferOutput<typeof blockSchema>;
|
|
255
447
|
export type SlideStep = InferOutput<typeof slideStepSchema>;
|
|
256
448
|
export type VideoStep = InferOutput<typeof videoStepSchema>;
|
|
@@ -260,4 +452,10 @@ export type Step = InferOutput<typeof stepSchema>;
|
|
|
260
452
|
export type StepType = Step["type"];
|
|
261
453
|
|
|
262
454
|
/** What can carry `reveal`, `revealAt` and `hideAt`: a block, or an item of a list. */
|
|
263
|
-
export type Timed = {
|
|
455
|
+
export type Timed = {
|
|
456
|
+
id: string;
|
|
457
|
+
reveal?: "step" | "with-previous";
|
|
458
|
+
revealAt?: string;
|
|
459
|
+
hideAt?: string;
|
|
460
|
+
delay?: number;
|
|
461
|
+
};
|
package/src/document/validate.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { toJsonSchema } from "@valibot/to-json-schema";
|
|
2
2
|
import { getDotPath, safeParse } from "valibot";
|
|
3
|
-
import { getCues } from "./cues";
|
|
4
|
-
import {
|
|
3
|
+
import { getCues, hasTrigger } from "./cues";
|
|
4
|
+
import { effectTargets, getEffectBlocks } from "./effects";
|
|
5
|
+
import { type Block, type Media, type SlideStep, type Step, stepSchema, type Timed } from "./schema";
|
|
5
6
|
|
|
6
7
|
export interface StepIssue {
|
|
7
8
|
/** Where in the document, as a dot path (`blocks.2.items.0.revealAt`). Empty for the document itself. */
|
|
@@ -14,7 +15,8 @@ export type StepValidation = { ok: true; step: Step } | { ok: false; issues: Ste
|
|
|
14
15
|
/**
|
|
15
16
|
* Checks a step document: its shape first, then what the shape cannot express - ids that are
|
|
16
17
|
* used twice, cues that end before they start or are out of order, media that ends before it
|
|
17
|
-
* starts,
|
|
18
|
+
* starts, `revealAt` / `hideAt` naming a cue that does not exist, a delay on a part that does not
|
|
19
|
+
* wait, an effect or a transition whose target is not on the step.
|
|
18
20
|
*/
|
|
19
21
|
export function validateStep(input: unknown): StepValidation {
|
|
20
22
|
let parsed = safeParse(stepSchema, input);
|
|
@@ -62,12 +64,80 @@ export function validateStep(input: unknown): StepValidation {
|
|
|
62
64
|
issues.push({ path: `${path}.${key}`, message: `There is no cue with the id "${cueId}".` });
|
|
63
65
|
}
|
|
64
66
|
}
|
|
67
|
+
|
|
68
|
+
if (part.delay != null && !hasTrigger(part) && !isEffect(part)) {
|
|
69
|
+
issues.push({ path: `${path}.delay`, message: "Only a part that waits to be shown can have a delay." });
|
|
70
|
+
}
|
|
65
71
|
}
|
|
72
|
+
issues.push(...effectIssues(step));
|
|
66
73
|
}
|
|
67
74
|
|
|
75
|
+
issues.push(...transitionIssues(step));
|
|
76
|
+
|
|
68
77
|
return issues.length > 0 ? { ok: false, issues } : { ok: true, step };
|
|
69
78
|
}
|
|
70
79
|
|
|
80
|
+
function isEffect(part: Timed) {
|
|
81
|
+
return (part as { type?: string }).type === "effect";
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The ids an effect or a transition can act on: every part of the slide except the effects, which show nothing. */
|
|
85
|
+
function targetableIds(step: SlideStep) {
|
|
86
|
+
let ids = new Set<string>();
|
|
87
|
+
for (let { part } of walk(step)) if (!isEffect(part)) ids.add(part.id);
|
|
88
|
+
return ids;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** An effect must name parts of the slide, and not itself or another effect. */
|
|
92
|
+
function effectIssues(step: SlideStep): StepIssue[] {
|
|
93
|
+
let issues: StepIssue[] = [];
|
|
94
|
+
let targetable = targetableIds(step);
|
|
95
|
+
let paths = new Map<string, string>();
|
|
96
|
+
for (let { part, path } of walk(step)) paths.set(part.id, path);
|
|
97
|
+
|
|
98
|
+
for (let effect of getEffectBlocks(step.blocks)) {
|
|
99
|
+
let path = paths.get(effect.id) ?? "";
|
|
100
|
+
let many = Array.isArray(effect.target);
|
|
101
|
+
effectTargets(effect).forEach((target, index) => {
|
|
102
|
+
let targetPath = many ? `${path}.target.${index}` : `${path}.target`;
|
|
103
|
+
if (targetable.has(target)) return;
|
|
104
|
+
let message = paths.has(target)
|
|
105
|
+
? "An effect cannot act on an effect."
|
|
106
|
+
: `There is no part with the id "${target}".`;
|
|
107
|
+
issues.push({ path: targetPath, message });
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return issues;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const SLIDE_TARGETS = new Set(["content", "background"]);
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* A transition must name something the step has: `content` and `background` are a slide's, and a
|
|
117
|
+
* part id must be a part of the slide (a column counts). `from` only means something for `slide`.
|
|
118
|
+
*/
|
|
119
|
+
function transitionIssues(step: Step): StepIssue[] {
|
|
120
|
+
let issues: StepIssue[] = [];
|
|
121
|
+
let partIds = new Set<string>();
|
|
122
|
+
if (step.type === "slide") partIds = targetableIds(step);
|
|
123
|
+
|
|
124
|
+
step.transitions?.forEach((transition, index) => {
|
|
125
|
+
let path = `transitions.${index}`;
|
|
126
|
+
let target = transition.target ?? "step";
|
|
127
|
+
if (SLIDE_TARGETS.has(target)) {
|
|
128
|
+
if (step.type !== "slide") {
|
|
129
|
+
issues.push({ path: `${path}.target`, message: `Only a slide has a "${target}" to animate.` });
|
|
130
|
+
}
|
|
131
|
+
} else if (target !== "step" && !partIds.has(target)) {
|
|
132
|
+
issues.push({ path: `${path}.target`, message: `There is no part with the id "${target}".` });
|
|
133
|
+
}
|
|
134
|
+
if (transition.from != null && transition.effect !== "slide") {
|
|
135
|
+
issues.push({ path: `${path}.from`, message: 'Only the "slide" effect has a direction.' });
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
return issues;
|
|
139
|
+
}
|
|
140
|
+
|
|
71
141
|
/** Every media of a step with its path, the video links on a slide included. */
|
|
72
142
|
function* mediaOf(step: Step): Generator<{ media: Media; path: string }> {
|
|
73
143
|
if (step.type === "video") yield { media: step.media, path: "media" };
|
|
@@ -82,30 +152,30 @@ function* mediaOf(step: Step): Generator<{ media: Media; path: string }> {
|
|
|
82
152
|
}
|
|
83
153
|
}
|
|
84
154
|
|
|
85
|
-
/**
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
155
|
+
/**
|
|
156
|
+
* Every timed part of a slide with its path. Columns and boxes are walked too, a box in a column
|
|
157
|
+
* included, and columns have ids of their own.
|
|
158
|
+
*/
|
|
159
|
+
function walk(step: SlideStep) {
|
|
160
|
+
return walkBlocks(step.blocks, "blocks");
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function* walkBlocks(blocks: Block[], basePath: string): Generator<{ part: Timed; path: string }> {
|
|
164
|
+
for (let [index, block] of blocks.entries()) {
|
|
165
|
+
let path = `${basePath}.${index}`;
|
|
89
166
|
yield { part: block, path };
|
|
90
167
|
|
|
91
|
-
if (block.type === "list") {
|
|
168
|
+
if (block.type === "list" || block.type === "canvas") {
|
|
92
169
|
for (let [itemIndex, item] of block.items.entries()) yield { part: item, path: `${path}.items.${itemIndex}` };
|
|
93
170
|
}
|
|
94
171
|
|
|
172
|
+
if (block.type === "box") yield* walkBlocks(block.blocks, `${path}.blocks`);
|
|
173
|
+
|
|
95
174
|
if (block.type === "columns") {
|
|
96
175
|
for (let [columnIndex, column] of block.columns.entries()) {
|
|
97
176
|
let columnPath = `${path}.columns.${columnIndex}`;
|
|
98
177
|
yield { part: { id: column.id }, path: columnPath };
|
|
99
|
-
|
|
100
|
-
for (let [childIndex, child] of column.blocks.entries()) {
|
|
101
|
-
let childPath = `${columnPath}.blocks.${childIndex}`;
|
|
102
|
-
yield { part: child, path: childPath };
|
|
103
|
-
if (child.type === "list") {
|
|
104
|
-
for (let [itemIndex, item] of child.items.entries()) {
|
|
105
|
-
yield { part: item, path: `${childPath}.items.${itemIndex}` };
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
178
|
+
yield* walkBlocks(column.blocks, `${columnPath}.blocks`);
|
|
109
179
|
}
|
|
110
180
|
}
|
|
111
181
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export { CoursePlayer, type CoursePlayerProps } from "./player/CoursePlayer";
|
|
2
|
-
export { StepView, type StepViewProps } from "./steps/StepView";
|
|
2
|
+
export { type SampleChrome, StepView, type StepViewProps } from "./steps/StepView";
|
|
3
|
+
export type { InsertContainer, InsertPlace } from "./steps/Blocks";
|
|
4
|
+
export {
|
|
5
|
+
CourseCompletion,
|
|
6
|
+
type CourseCompletionProps,
|
|
7
|
+
hasCompletionText,
|
|
8
|
+
sanitizeCompletionHtml,
|
|
9
|
+
} from "./completion/CourseCompletion";
|
|
3
10
|
export { type CueClock, useCueClock } from "./media/useCueClock";
|
|
4
11
|
export {
|
|
5
12
|
elementHandle,
|
|
@@ -29,20 +36,43 @@ export {
|
|
|
29
36
|
getActiveCue,
|
|
30
37
|
getCueEnd,
|
|
31
38
|
getCues,
|
|
39
|
+
getRevealLeaders,
|
|
40
|
+
getRevealNavigation,
|
|
41
|
+
getRevealState,
|
|
32
42
|
getRevealSteps,
|
|
33
43
|
getStartedCueIds,
|
|
34
44
|
getTimedParts,
|
|
35
45
|
hasCueText,
|
|
46
|
+
hasTrigger,
|
|
47
|
+
isDue,
|
|
48
|
+
isNarratedSlide,
|
|
36
49
|
isVisible,
|
|
50
|
+
type RevealNavigation,
|
|
37
51
|
type RevealState,
|
|
38
52
|
} from "./document/cues";
|
|
53
|
+
export {
|
|
54
|
+
DEFAULT_EFFECT_DURATION,
|
|
55
|
+
effectTargets,
|
|
56
|
+
getActiveEffects,
|
|
57
|
+
getEffectBlocks,
|
|
58
|
+
getPartEffects,
|
|
59
|
+
type PartEffect,
|
|
60
|
+
} from "./document/effects";
|
|
39
61
|
export {
|
|
40
62
|
type Block,
|
|
41
63
|
blockSchema,
|
|
64
|
+
type BoxBlock,
|
|
65
|
+
type BoxContentBlock,
|
|
66
|
+
boxBlockSchema,
|
|
67
|
+
boxContentSchema,
|
|
42
68
|
type CalloutBlock,
|
|
69
|
+
calloutBlockSchema,
|
|
43
70
|
type ColumnsBlock,
|
|
44
71
|
type ContentBlock,
|
|
72
|
+
contentBlockSchema,
|
|
45
73
|
type Cue,
|
|
74
|
+
type EffectBlock,
|
|
75
|
+
effectBlockSchema,
|
|
46
76
|
type ImageSize,
|
|
47
77
|
type Media,
|
|
48
78
|
type Narration,
|
|
@@ -51,9 +81,24 @@ export {
|
|
|
51
81
|
type SlideStep,
|
|
52
82
|
STEP_SCHEMA_VERSION,
|
|
53
83
|
type Step,
|
|
84
|
+
type StepTransition,
|
|
54
85
|
type StepType,
|
|
55
86
|
stepSchema,
|
|
87
|
+
type SurfaceVariant,
|
|
88
|
+
TONES,
|
|
89
|
+
type Tone,
|
|
90
|
+
transitionSchema,
|
|
56
91
|
type Timed,
|
|
57
92
|
type VideoStep,
|
|
58
93
|
} from "./document/schema";
|
|
59
94
|
export { getStepJsonSchema, type StepIssue, type StepValidation, validateStep } from "./document/validate";
|
|
95
|
+
export {
|
|
96
|
+
DEFAULT_TRANSITION_DURATION,
|
|
97
|
+
DEFAULT_TRANSITIONS,
|
|
98
|
+
getStepTransitions,
|
|
99
|
+
planStepTransition,
|
|
100
|
+
type TransitionDirection,
|
|
101
|
+
type TransitionPlan,
|
|
102
|
+
type TransitionStep,
|
|
103
|
+
} from "./transitions/plan";
|
|
104
|
+
export { playStepTransition, type StepTransitionOptions } from "./transitions/playStepTransition";
|
package/src/media/Media.css
CHANGED
|
@@ -94,3 +94,19 @@
|
|
|
94
94
|
height: 100%;
|
|
95
95
|
color: white;
|
|
96
96
|
}
|
|
97
|
+
|
|
98
|
+
/* A phone on its side: slimmer controls and smaller subtitles, so they cover less of the slide */
|
|
99
|
+
@media (orientation: landscape) and (max-height: 500px) {
|
|
100
|
+
.ob-course-media-controls {
|
|
101
|
+
padding-block: 0.125rem;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.ob-course-subtitles {
|
|
105
|
+
inset-block-end: var(--ds-size-2, 0.5rem);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.ob-course-subtitles__text {
|
|
109
|
+
font-size: max(0.75rem, 3.6vh);
|
|
110
|
+
font-size: max(0.75rem, 3.6dvh);
|
|
111
|
+
}
|
|
112
|
+
}
|
package/src/media/icons.tsx
CHANGED
|
@@ -74,3 +74,11 @@ export function CloseIcon(props: IconProps) {
|
|
|
74
74
|
</Icon>
|
|
75
75
|
);
|
|
76
76
|
}
|
|
77
|
+
|
|
78
|
+
export function ExitFullscreenIcon(props: IconProps) {
|
|
79
|
+
return (
|
|
80
|
+
<Icon {...props}>
|
|
81
|
+
<path d="M8 4h2v6H4V8h4V4Zm6 0h2v4h4v2h-6V4ZM4 14h6v6H8v-4H4v-2Zm10 0h6v2h-4v4h-2v-6Z" />
|
|
82
|
+
</Icon>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
@@ -155,3 +155,79 @@
|
|
|
155
155
|
height: 1.5em;
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
+
|
|
159
|
+
/*
|
|
160
|
+
* Full screen: the step fills the screen, with the buttons under it and a small button in the corner
|
|
161
|
+
* to leave. Native full screen puts the player on the whole screen itself; the immersive mode (Safari
|
|
162
|
+
* on iPhone, which only puts videos on the screen) lays it over the page.
|
|
163
|
+
*/
|
|
164
|
+
.ob-course-player {
|
|
165
|
+
position: relative;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.ob-course-player.is-full-screen {
|
|
169
|
+
height: 100vh;
|
|
170
|
+
height: 100dvh;
|
|
171
|
+
padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
|
|
172
|
+
|
|
173
|
+
> .ob-course-player__header,
|
|
174
|
+
.ob-course-category-header {
|
|
175
|
+
display: none;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.ob-course-player.is-immersive {
|
|
180
|
+
position: fixed;
|
|
181
|
+
inset: 0;
|
|
182
|
+
z-index: 2147483000;
|
|
183
|
+
overscroll-behavior: contain;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.ob-course-player__leave-full-screen {
|
|
187
|
+
position: absolute;
|
|
188
|
+
top: max(var(--ds-size-2, 0.5rem), env(safe-area-inset-top));
|
|
189
|
+
right: max(var(--ds-size-2, 0.5rem), env(safe-area-inset-right));
|
|
190
|
+
z-index: 3;
|
|
191
|
+
opacity: 0.85;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/*
|
|
195
|
+
* A phone on its side has little height: the header and the buttons get slim (they also take the
|
|
196
|
+
* small size, set from the same query in CoursePlayer), so the slide keeps most of the screen.
|
|
197
|
+
*/
|
|
198
|
+
@media (orientation: landscape) and (max-height: 500px) {
|
|
199
|
+
.ob-course-player__header {
|
|
200
|
+
padding: 0.125rem max(var(--ds-size-3, 0.75rem), env(safe-area-inset-right)) 0.125rem
|
|
201
|
+
max(var(--ds-size-3, 0.75rem), env(safe-area-inset-left));
|
|
202
|
+
font-size: 0.875rem;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.ob-course-player__controls {
|
|
206
|
+
gap: var(--ds-size-2, 0.5rem);
|
|
207
|
+
padding: 0.25rem max(var(--ds-size-3, 0.75rem), env(safe-area-inset-right))
|
|
208
|
+
max(0.25rem, env(safe-area-inset-bottom)) max(var(--ds-size-3, 0.75rem), env(safe-area-inset-left));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.ob-course-player__status {
|
|
212
|
+
font-size: 0.75rem;
|
|
213
|
+
line-height: 1.25;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/* The same slim chrome in an editor's preview of a phone on its side, which the media query cannot see. */
|
|
218
|
+
.ob-course-player.is-compact {
|
|
219
|
+
> .ob-course-player__header {
|
|
220
|
+
padding: 0.125rem var(--ds-size-3, 0.75rem);
|
|
221
|
+
font-size: 0.875rem;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
> .ob-course-player__controls {
|
|
225
|
+
gap: var(--ds-size-2, 0.5rem);
|
|
226
|
+
padding: 0.25rem var(--ds-size-3, 0.75rem);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.ob-course-player__status {
|
|
230
|
+
font-size: 0.75rem;
|
|
231
|
+
line-height: 1.25;
|
|
232
|
+
}
|
|
233
|
+
}
|