@olenbetong/synergi-course 2.0.0 → 2.1.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 +115 -14
- package/es/document/effects.d.ts +30 -0
- package/es/document/effects.js +74 -0
- package/es/document/schema.d.ts +924 -136
- package/es/document/schema.js +139 -5
- package/es/document/validate.d.ts +2 -1
- package/es/document/validate.js +73 -2
- package/es/index.d.ts +6 -2
- 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 +58 -0
- package/es/player/CoursePlayer.js +27 -13
- 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 +20 -1
- package/es/steps/Blocks.js +103 -22
- package/es/steps/Markdown.d.ts +7 -1
- package/es/steps/Markdown.js +31 -4
- 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 +38 -15
- package/es/steps/StepBodyProps.d.ts +7 -1
- package/es/steps/StepView.css +328 -12
- package/es/steps/StepView.d.ts +8 -2
- package/es/steps/StepView.js +2 -2
- 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 +3 -1
- 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/cues.ts +142 -13
- package/src/document/document.test.ts +1 -1
- package/src/document/effects.ts +105 -0
- package/src/document/reveal.test.ts +263 -0
- package/src/document/schema.ts +161 -5
- package/src/document/validate.ts +77 -3
- package/src/index.ts +35 -0
- package/src/media/Media.css +16 -0
- package/src/media/icons.tsx +8 -0
- package/src/player/CoursePlayer.css +58 -0
- package/src/player/CoursePlayer.test.tsx +70 -6
- package/src/player/CoursePlayer.tsx +68 -17
- 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 +166 -26
- package/src/steps/Markdown.test.tsx +43 -0
- package/src/steps/Markdown.tsx +42 -4
- package/src/steps/Presence.test.tsx +82 -0
- package/src/steps/RevealMotion.ts +66 -0
- package/src/steps/SlideStepView.tsx +67 -17
- package/src/steps/StepBodyProps.ts +7 -1
- package/src/steps/StepView.css +328 -12
- package/src/steps/StepView.test.tsx +41 -0
- package/src/steps/StepView.tsx +9 -1
- 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 +3 -1
- 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/es/steps/StepView.css
CHANGED
|
@@ -21,13 +21,15 @@
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/* --ob-course-step-pad: the room around a step's content, which a slide's background reaches across */
|
|
24
25
|
.ob-course-step__body {
|
|
26
|
+
--ob-course-step-pad: clamp(1rem, 4cqi, 3rem);
|
|
25
27
|
flex: 1 0 auto;
|
|
26
28
|
display: flex;
|
|
27
29
|
flex-direction: column;
|
|
28
30
|
font-size: clamp(1rem, 0.9rem + 0.8cqi, 1.6rem);
|
|
29
31
|
line-height: 1.5;
|
|
30
|
-
padding:
|
|
32
|
+
padding: var(--ob-course-step-pad);
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
.ob-course-step--standalone {
|
|
@@ -41,8 +43,18 @@
|
|
|
41
43
|
display: flex;
|
|
42
44
|
flex-direction: column;
|
|
43
45
|
position: relative;
|
|
44
|
-
margin: calc(-1 *
|
|
45
|
-
padding:
|
|
46
|
+
margin: calc(-1 * var(--ob-course-step-pad));
|
|
47
|
+
padding: var(--ob-course-step-pad);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.ob-course-slide--background {
|
|
51
|
+
isolation: isolate;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.ob-course-slide__background {
|
|
55
|
+
position: absolute;
|
|
56
|
+
inset: 0;
|
|
57
|
+
z-index: -1;
|
|
46
58
|
background-size: cover;
|
|
47
59
|
background-position: center;
|
|
48
60
|
}
|
|
@@ -53,7 +65,8 @@
|
|
|
53
65
|
gap: 0.9em;
|
|
54
66
|
width: 100%;
|
|
55
67
|
max-width: 70rem;
|
|
56
|
-
|
|
68
|
+
/* In the middle of the step while it fits; auto margins give way when it has to scroll */
|
|
69
|
+
margin: auto;
|
|
57
70
|
}
|
|
58
71
|
|
|
59
72
|
.ob-course-slide--centered {
|
|
@@ -69,7 +82,20 @@
|
|
|
69
82
|
}
|
|
70
83
|
}
|
|
71
84
|
|
|
72
|
-
|
|
85
|
+
/* The doubled class lets a width set on the slide win over a layout's own. */
|
|
86
|
+
.ob-course-slide.ob-course-slide--narrow .ob-course-slide__content {
|
|
87
|
+
max-width: 36rem;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.ob-course-slide.ob-course-slide--medium .ob-course-slide__content {
|
|
91
|
+
max-width: 52rem;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.ob-course-slide.ob-course-slide--wide .ob-course-slide__content {
|
|
95
|
+
max-width: 70rem;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.ob-course-slide--background:not(.ob-course-slide--bare) .ob-course-slide__content {
|
|
73
99
|
padding: clamp(0.75rem, 3cqi, 2rem);
|
|
74
100
|
border-radius: var(--ds-border-radius-lg, 8px);
|
|
75
101
|
background: color-mix(in srgb, var(--ds-color-neutral-background-default) 88%, transparent);
|
|
@@ -105,14 +131,13 @@
|
|
|
105
131
|
}
|
|
106
132
|
|
|
107
133
|
.ob-course-slide--title.ob-course-slide--background {
|
|
108
|
-
isolation: isolate;
|
|
109
134
|
color: white;
|
|
110
135
|
|
|
111
|
-
|
|
136
|
+
/* The shade belongs to the picture, so it moves with the background in a transition */
|
|
137
|
+
.ob-course-slide__background::after {
|
|
112
138
|
content: "";
|
|
113
139
|
position: absolute;
|
|
114
140
|
inset: 0;
|
|
115
|
-
z-index: -1;
|
|
116
141
|
background: rgb(0 0 0 / 0.4);
|
|
117
142
|
}
|
|
118
143
|
|
|
@@ -133,14 +158,91 @@
|
|
|
133
158
|
}
|
|
134
159
|
}
|
|
135
160
|
|
|
161
|
+
/*
|
|
162
|
+
* A banner: the image runs from edge to edge in its own proportions, between two coloured bars,
|
|
163
|
+
* with the words on top of it. A theme sets the bars with --ob-course-banner-border.
|
|
164
|
+
*/
|
|
165
|
+
.ob-course-slide--banner {
|
|
166
|
+
padding-inline: 0;
|
|
167
|
+
|
|
168
|
+
.ob-course-slide__narration {
|
|
169
|
+
padding-inline: var(--ob-course-step-pad);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.ob-course-banner {
|
|
174
|
+
display: flex;
|
|
175
|
+
flex-direction: column;
|
|
176
|
+
margin-block: auto;
|
|
177
|
+
|
|
178
|
+
&::before,
|
|
179
|
+
&::after {
|
|
180
|
+
content: "";
|
|
181
|
+
flex: none;
|
|
182
|
+
height: 0.75em;
|
|
183
|
+
background: var(--ob-course-banner-border, linear-gradient(45deg, #002878, #002878 30%, #00722a 70%, #00722a));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.ob-course-banner__stage {
|
|
188
|
+
display: grid;
|
|
189
|
+
|
|
190
|
+
> * {
|
|
191
|
+
grid-area: 1 / 1;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.ob-course-banner__image {
|
|
196
|
+
display: block;
|
|
197
|
+
width: 100%;
|
|
198
|
+
height: 100%;
|
|
199
|
+
min-height: 8em;
|
|
200
|
+
object-fit: cover;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.ob-course-banner .ob-course-slide__content {
|
|
204
|
+
z-index: 1;
|
|
205
|
+
justify-content: center;
|
|
206
|
+
align-items: center;
|
|
207
|
+
max-width: none;
|
|
208
|
+
margin: 0;
|
|
209
|
+
padding: 1em clamp(1rem, 4cqi, 3rem);
|
|
210
|
+
background: rgb(0 0 0 / 0.2);
|
|
211
|
+
color: white;
|
|
212
|
+
text-align: center;
|
|
213
|
+
text-shadow: 0.05em 0.05em rgb(0 0 0 / 0.5);
|
|
214
|
+
|
|
215
|
+
> .ob-course-block--heading:first-child {
|
|
216
|
+
font-size: clamp(2em, 1.2em + 4cqi, 3.6em);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.ob-course-block--text {
|
|
220
|
+
font-size: 1.2em;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
136
224
|
.ob-course-slide__narration {
|
|
137
225
|
width: 100%;
|
|
138
226
|
max-width: 70rem;
|
|
139
|
-
margin: auto
|
|
227
|
+
margin-inline: auto;
|
|
140
228
|
padding-top: 1em;
|
|
141
229
|
font-size: 1rem;
|
|
142
230
|
}
|
|
143
231
|
|
|
232
|
+
/*
|
|
233
|
+
* Over a background image the controls get the same surface as the content, so the button and
|
|
234
|
+
* the time can be read on a light picture and on a dark one.
|
|
235
|
+
*/
|
|
236
|
+
.ob-course-slide--background .ob-course-slide__narration {
|
|
237
|
+
margin-top: 1em;
|
|
238
|
+
padding: 0 var(--ds-size-3, 0.75rem);
|
|
239
|
+
border-radius: var(--ds-border-radius-lg, 8px);
|
|
240
|
+
background: color-mix(in srgb, var(--ds-color-neutral-background-default) 88%, transparent);
|
|
241
|
+
box-shadow: var(--ds-shadow-md);
|
|
242
|
+
color: var(--ds-color-neutral-text-default);
|
|
243
|
+
text-shadow: none;
|
|
244
|
+
}
|
|
245
|
+
|
|
144
246
|
/* Leaves room for the subtitle above the narration controls. */
|
|
145
247
|
.ob-course-slide:has(.ob-course-slide__narration) > .ob-course-subtitles {
|
|
146
248
|
inset-block-end: 4.5rem;
|
|
@@ -156,6 +258,79 @@
|
|
|
156
258
|
}
|
|
157
259
|
}
|
|
158
260
|
|
|
261
|
+
/*
|
|
262
|
+
* The unit an effect's move is given in: the slide's own text size, computed where it is declared
|
|
263
|
+
* so a move is the same on a large heading as on a line of text.
|
|
264
|
+
*/
|
|
265
|
+
@property --ob-course-em {
|
|
266
|
+
syntax: "<length>";
|
|
267
|
+
inherits: true;
|
|
268
|
+
initial-value: 16px;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.ob-course-slide {
|
|
272
|
+
--ob-course-em: 1em;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/*
|
|
276
|
+
* An effect's scale works from where the text starts, so a left-aligned heading shrinks towards
|
|
277
|
+
* its own edge instead of drifting inwards. Parts that stand in the middle - on a centred, title or
|
|
278
|
+
* banner slide, images, columns and canvas items - scale from their centre, the default.
|
|
279
|
+
*/
|
|
280
|
+
.ob-course-slide
|
|
281
|
+
:is(
|
|
282
|
+
.ob-course-block--heading,
|
|
283
|
+
.ob-course-block--text,
|
|
284
|
+
.ob-course-block--list,
|
|
285
|
+
.ob-course-block--quote,
|
|
286
|
+
.ob-course-block--callout,
|
|
287
|
+
.ob-course-block--video-link,
|
|
288
|
+
.ob-course-list-item
|
|
289
|
+
) {
|
|
290
|
+
transform-origin: left center;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.ob-course-slide:is(.ob-course-slide--centered, .ob-course-slide--title, .ob-course-slide--banner)
|
|
294
|
+
:is(
|
|
295
|
+
.ob-course-block--heading,
|
|
296
|
+
.ob-course-block--text,
|
|
297
|
+
.ob-course-block--list,
|
|
298
|
+
.ob-course-block--quote,
|
|
299
|
+
.ob-course-block--callout,
|
|
300
|
+
.ob-course-block--video-link,
|
|
301
|
+
.ob-course-list-item
|
|
302
|
+
) {
|
|
303
|
+
transform-origin: center;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/* A passing part that came into the page after the slide was drawn */
|
|
307
|
+
.ob-course-block.is-entering,
|
|
308
|
+
.ob-course-list-item.is-entering,
|
|
309
|
+
.ob-course-canvas__item.is-entering {
|
|
310
|
+
animation: ob-course-part-in 0.3s ease backwards;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/* A passing part on its way out: the slide has lifted it out of the flow over its last place */
|
|
314
|
+
.ob-course-block.is-leaving,
|
|
315
|
+
.ob-course-list-item.is-leaving,
|
|
316
|
+
.ob-course-canvas__item.is-leaving {
|
|
317
|
+
opacity: 0;
|
|
318
|
+
pointer-events: none;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
@keyframes ob-course-part-in {
|
|
322
|
+
from {
|
|
323
|
+
opacity: 0;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
@media (prefers-reduced-motion: reduce) {
|
|
328
|
+
[data-part] {
|
|
329
|
+
transition: none !important;
|
|
330
|
+
animation: none !important;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
159
334
|
.ob-course-list-item {
|
|
160
335
|
transition: opacity 0.3s ease;
|
|
161
336
|
|
|
@@ -169,6 +344,22 @@
|
|
|
169
344
|
}
|
|
170
345
|
}
|
|
171
346
|
|
|
347
|
+
.ob-course-look--caps {
|
|
348
|
+
text-transform: uppercase;
|
|
349
|
+
letter-spacing: 0.02em;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.ob-course-look--shadow {
|
|
353
|
+
/* Hard, not blurred: the look the courses have used on titles */
|
|
354
|
+
text-shadow: 0.05em 0.05em 0 rgb(0 0 0 / 0.5);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
.ob-course-sublist {
|
|
358
|
+
margin: 0.4em 0 0;
|
|
359
|
+
padding-inline-start: 1.4em;
|
|
360
|
+
font-size: 0.9em;
|
|
361
|
+
}
|
|
362
|
+
|
|
172
363
|
.ob-course-heading--1,
|
|
173
364
|
.ob-course-heading--2,
|
|
174
365
|
.ob-course-heading--3 {
|
|
@@ -199,11 +390,28 @@
|
|
|
199
390
|
margin-top: 0.75em;
|
|
200
391
|
}
|
|
201
392
|
|
|
393
|
+
/* A link looks like one whatever the page does with links */
|
|
202
394
|
a {
|
|
203
395
|
color: var(--ds-color-brand-text-default);
|
|
396
|
+
text-decoration: underline;
|
|
397
|
+
text-decoration-thickness: max(1px, 0.06em);
|
|
398
|
+
text-underline-offset: 0.15em;
|
|
399
|
+
|
|
400
|
+
&:hover {
|
|
401
|
+
text-decoration-thickness: max(2px, 0.12em);
|
|
402
|
+
}
|
|
204
403
|
}
|
|
205
404
|
}
|
|
206
405
|
|
|
406
|
+
/* `data-color` picks the colour scale, as on a callout. */
|
|
407
|
+
.ob-course-tone {
|
|
408
|
+
color: var(--ds-color-text-subtle);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.ob-course-markdown big {
|
|
412
|
+
font-size: 1.25em;
|
|
413
|
+
}
|
|
414
|
+
|
|
207
415
|
.ob-course-markdown--inline {
|
|
208
416
|
display: inline;
|
|
209
417
|
}
|
|
@@ -309,6 +517,59 @@
|
|
|
309
517
|
gap: 0.9em;
|
|
310
518
|
}
|
|
311
519
|
|
|
520
|
+
/*
|
|
521
|
+
* A canvas keeps its proportions and everything on it scales with its width, the text included,
|
|
522
|
+
* so the parts stay where they were put. Below 40rem it stops shrinking and scrolls sideways
|
|
523
|
+
* instead, because the text would be too small to read. Light whatever the page is, like paper.
|
|
524
|
+
*/
|
|
525
|
+
.ob-course-block--canvas {
|
|
526
|
+
overflow-x: auto;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
.ob-course-canvas {
|
|
530
|
+
position: relative;
|
|
531
|
+
container-type: inline-size;
|
|
532
|
+
width: 100%;
|
|
533
|
+
min-width: 40rem;
|
|
534
|
+
overflow: hidden;
|
|
535
|
+
border-radius: var(--ds-border-radius-md, 4px);
|
|
536
|
+
background: white;
|
|
537
|
+
color: #1e2b3c;
|
|
538
|
+
text-align: start;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
.ob-course-canvas__item {
|
|
542
|
+
position: absolute;
|
|
543
|
+
margin: 0;
|
|
544
|
+
transition: opacity 0.3s ease;
|
|
545
|
+
|
|
546
|
+
&.is-pending {
|
|
547
|
+
visibility: hidden;
|
|
548
|
+
opacity: 0;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
.ob-course-canvas__image {
|
|
553
|
+
max-width: none;
|
|
554
|
+
object-fit: contain;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.ob-course-canvas__text {
|
|
558
|
+
font-size: calc(1.7cqi * var(--ob-course-canvas-size, 1));
|
|
559
|
+
line-height: 1.35;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
.ob-course-canvas__text--solid,
|
|
563
|
+
.ob-course-canvas__text--frame {
|
|
564
|
+
padding: 0.2em 0.4em;
|
|
565
|
+
background: white;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
.ob-course-canvas__text--frame {
|
|
569
|
+
padding: 0.8em;
|
|
570
|
+
border: 0.3em solid var(--ds-color-border-strong);
|
|
571
|
+
}
|
|
572
|
+
|
|
312
573
|
.ob-course-video-dialog {
|
|
313
574
|
width: min(64rem, 100vw - 2rem);
|
|
314
575
|
max-width: none;
|
|
@@ -316,19 +577,40 @@
|
|
|
316
577
|
|
|
317
578
|
/* Video, document and quiz steps */
|
|
318
579
|
|
|
580
|
+
/*
|
|
581
|
+
* A video is as large as fits: the step's width, or the width its height allows, so the whole
|
|
582
|
+
* picture and its controls are in view without scrolling. The step is a size container for that.
|
|
583
|
+
*/
|
|
584
|
+
.ob-course-step__body:has(> .ob-course-video-step, > .ob-course-video-stage) {
|
|
585
|
+
flex: 1 1 0;
|
|
586
|
+
min-height: 0;
|
|
587
|
+
}
|
|
588
|
+
|
|
319
589
|
.ob-course-video-step {
|
|
590
|
+
flex: 1 1 0;
|
|
591
|
+
display: flex;
|
|
592
|
+
align-items: center;
|
|
593
|
+
justify-content: center;
|
|
594
|
+
container-type: size;
|
|
320
595
|
width: 100%;
|
|
321
596
|
max-width: 80rem;
|
|
322
|
-
|
|
597
|
+
min-height: 14rem;
|
|
598
|
+
margin-inline: auto;
|
|
599
|
+
|
|
600
|
+
/* 3.5rem: the row of controls under the picture */
|
|
601
|
+
> .ob-course-video {
|
|
602
|
+
width: min(100%, (100cqb - 3.5rem) * 16 / 9);
|
|
603
|
+
}
|
|
323
604
|
}
|
|
324
605
|
|
|
325
606
|
/* A video over a background image fills the step the way a slide's background does. */
|
|
326
607
|
.ob-course-video-stage {
|
|
327
608
|
flex: 1;
|
|
609
|
+
min-height: 0;
|
|
328
610
|
display: flex;
|
|
329
611
|
flex-direction: column;
|
|
330
|
-
margin: calc(-1 *
|
|
331
|
-
padding:
|
|
612
|
+
margin: calc(-1 * var(--ob-course-step-pad));
|
|
613
|
+
padding: var(--ob-course-step-pad);
|
|
332
614
|
background-size: cover;
|
|
333
615
|
background-position: center;
|
|
334
616
|
|
|
@@ -378,3 +660,37 @@
|
|
|
378
660
|
.ob-course-slide [data-part] {
|
|
379
661
|
scroll-margin-block: var(--ds-size-4, 1rem);
|
|
380
662
|
}
|
|
663
|
+
|
|
664
|
+
/*
|
|
665
|
+
* A phone on its side: little height. The text scales with the height as well as the width, the room
|
|
666
|
+
* around it shrinks, and the narration controls and subtitles take less of the slide.
|
|
667
|
+
*/
|
|
668
|
+
@media (orientation: landscape) and (max-height: 500px) {
|
|
669
|
+
.ob-course-step__body {
|
|
670
|
+
--ob-course-step-pad: clamp(0.5rem, 2cqi, 1rem);
|
|
671
|
+
font-size: min(clamp(1rem, 0.9rem + 0.8cqi, 1.6rem), max(0.8125rem, 4.2vh));
|
|
672
|
+
font-size: min(clamp(1rem, 0.9rem + 0.8cqi, 1.6rem), max(0.8125rem, 4.2dvh));
|
|
673
|
+
line-height: 1.4;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
.ob-course-slide__content {
|
|
677
|
+
gap: 0.6em;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
.ob-course-slide--title .ob-course-slide__content > .ob-course-block--heading:first-child,
|
|
681
|
+
.ob-course-banner .ob-course-slide__content > .ob-course-block--heading:first-child {
|
|
682
|
+
font-size: clamp(1.5em, 1em + 3cqi, 2.4em);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
.ob-course-slide__narration {
|
|
686
|
+
padding-top: 0.25em;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
.ob-course-slide--background .ob-course-slide__narration {
|
|
690
|
+
margin-top: 0.4em;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
.ob-course-slide:has(.ob-course-slide__narration) > .ob-course-subtitles {
|
|
694
|
+
inset-block-end: 3rem;
|
|
695
|
+
}
|
|
696
|
+
}
|
package/es/steps/StepView.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
+
import type { RevealNavigation } from "../document/cues";
|
|
2
3
|
import type { Step } from "../document/schema";
|
|
3
4
|
import type { PlayerBranding, PlayerCategory, PlayerMode, QuizAdapter, ResolveAsset } from "../types";
|
|
4
5
|
import type { StepBodyProps } from "./StepBodyProps";
|
|
@@ -24,8 +25,13 @@ export interface StepViewProps {
|
|
|
24
25
|
quiz?: QuizAdapter;
|
|
25
26
|
/** The slide the step belongs to, passed to the quiz adapter. */
|
|
26
27
|
slideId?: number;
|
|
27
|
-
/** How many `reveal: "step"` parts
|
|
28
|
+
/** How many `reveal: "step"` parts count as pressed. Every part is shown when left out. */
|
|
28
29
|
stepsShown?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Where Next and Back would take a slide from `stepsShown`, skipping presses that show nothing
|
|
32
|
+
* new, and how many presses show something: for a stepper that counts the way the player does.
|
|
33
|
+
*/
|
|
34
|
+
onRevealNavigation?(navigation: RevealNavigation): void;
|
|
29
35
|
/** The band above the step naming its part of the course, as the player shows it. None when left out. */
|
|
30
36
|
category?: PlayerCategory | null;
|
|
31
37
|
/**
|
|
@@ -35,4 +41,4 @@ export interface StepViewProps {
|
|
|
35
41
|
branding?: PlayerBranding | null;
|
|
36
42
|
}
|
|
37
43
|
/** One step on its own, without the course chrome: for previewing a step while it is edited. */
|
|
38
|
-
export declare function StepView({ step, resolveAsset, mode, quiz, slideId, stepsShown, category, branding, }: StepViewProps): import("react").JSX.Element;
|
|
44
|
+
export declare function StepView({ step, resolveAsset, mode, quiz, slideId, stepsShown, category, branding, onRevealNavigation, }: StepViewProps): import("react").JSX.Element;
|
package/es/steps/StepView.js
CHANGED
|
@@ -37,8 +37,8 @@ export function StepFrame({ category, branding, children, }) {
|
|
|
37
37
|
return (_jsxs(_Fragment, { children: [category && _jsx(CategoryHeader, { ...category, branding: branding }), _jsx("div", { className: "ob-course-step__body", children: children })] }));
|
|
38
38
|
}
|
|
39
39
|
/** One step on its own, without the course chrome: for previewing a step while it is edited. */
|
|
40
|
-
export function StepView({ step, resolveAsset, mode = "preview", quiz, slideId = 0, stepsShown, category, branding, }) {
|
|
40
|
+
export function StepView({ step, resolveAsset, mode = "preview", quiz, slideId = 0, stepsShown, category, branding, onRevealNavigation, }) {
|
|
41
41
|
let [subtitles, setSubtitles] = useState(true);
|
|
42
|
-
return (_jsx("div", { className: "ob-course-step ob-course-step--standalone", children: _jsx(StepFrame, { category: category, branding: branding, children: _jsx(StepBody, { step: step, slideId: slideId, mode: mode, resolveAsset: resolveAsset, quiz: quiz, stepsShown: stepsShown ?? Number.POSITIVE_INFINITY, subtitles: subtitles, onSubtitlesChange: setSubtitles, onDoneChange: ignore }) }) }));
|
|
42
|
+
return (_jsx("div", { className: "ob-course-step ob-course-step--standalone", children: _jsx(StepFrame, { category: category, branding: branding, children: _jsx(StepBody, { step: step, slideId: slideId, mode: mode, resolveAsset: resolveAsset, quiz: quiz, stepsShown: stepsShown ?? Number.POSITIVE_INFINITY, subtitles: subtitles, onSubtitlesChange: setSubtitles, onDoneChange: ignore, onRevealNavigation: onRevealNavigation }) }) }));
|
|
43
43
|
}
|
|
44
44
|
function ignore() { }
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
import type { PartEffect } from "../document/effects";
|
|
3
|
+
/** The reveal fade, in milliseconds: parts fade in, and passing parts fade out, this fast. */
|
|
4
|
+
export declare const FADE_MS = 300;
|
|
5
|
+
/** How long a part takes to glide to the place a change of the slide pushed it to. */
|
|
6
|
+
export declare const GLIDE_MS = 300;
|
|
7
|
+
/** Where a part stands, relative to the slide, and whether it can be seen there. */
|
|
8
|
+
export interface PartBox {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
/** Neither waiting to be shown nor fading out, itself or by a part around it. */
|
|
14
|
+
shown: boolean;
|
|
15
|
+
/** The nearest part around it, if any. */
|
|
16
|
+
parent: string | null;
|
|
17
|
+
}
|
|
18
|
+
export interface Glide {
|
|
19
|
+
id: string;
|
|
20
|
+
/** How far the part was from where it is now: it starts there and glides to nothing. */
|
|
21
|
+
dx: number;
|
|
22
|
+
dy: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The parts that a change pushed to another place, with how far, so they can glide there instead
|
|
26
|
+
* of jumping. A part that just appeared fades in where it is, and a part that cannot be seen has
|
|
27
|
+
* nothing to show. A part inside one that glides only glides by what it moved within it, so the
|
|
28
|
+
* two do not add up to too much. `after` lists parts around a part before the part itself, as the
|
|
29
|
+
* document does.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getGlides(before: ReadonlyMap<string, PartBox>, after: ReadonlyMap<string, PartBox>, threshold?: number): Glide[];
|
|
32
|
+
/** Every part in the slide with its box. Sizes are layout sizes, without an effect's scale. */
|
|
33
|
+
export declare function measureParts(root: HTMLElement): Map<string, PartBox>;
|
|
34
|
+
/**
|
|
35
|
+
* Lifts the parts that started to fade out out of the flow, onto the box they had before the
|
|
36
|
+
* change, so the part coming in their place takes it at once and nothing jumps when they go.
|
|
37
|
+
*/
|
|
38
|
+
export declare function pinLeaving(root: HTMLElement, before: ReadonlyMap<string, PartBox>): void;
|
|
39
|
+
/** Puts a part that came back while it was fading out into the flow again. */
|
|
40
|
+
export declare function unpinReturned(root: HTMLElement): void;
|
|
41
|
+
/** Starts the glides on the elements; `composite: "add"` keeps an effect's own move under them. */
|
|
42
|
+
export declare function runGlides(root: HTMLElement, glides: Glide[]): void;
|
|
43
|
+
/** Width to height from a canvas's `aspect`, e.g. `16/9`. */
|
|
44
|
+
export declare function aspectRatio(aspect: string | undefined): number;
|
|
45
|
+
export type PartState = "shown" | "pending" | "leaving";
|
|
46
|
+
/**
|
|
47
|
+
* The inline style a part's effects and reveal delay give it. A move on a canvas item is in percent
|
|
48
|
+
* of the canvas (`cqi` is a percent of its width; the height is the width over the aspect), on any
|
|
49
|
+
* other part in the slide's text size. The transition lists the reveal fade too, since an inline
|
|
50
|
+
* transition replaces the stylesheet's.
|
|
51
|
+
*/
|
|
52
|
+
export declare function partStyle({ effect, delay, state, canvasAspect, }: {
|
|
53
|
+
effect?: PartEffect;
|
|
54
|
+
/** The part's `delay`: how long after it is due it shows. */
|
|
55
|
+
delay?: number;
|
|
56
|
+
state: PartState;
|
|
57
|
+
/** Set for an item on a canvas: the canvas's width over its height. */
|
|
58
|
+
canvasAspect?: number;
|
|
59
|
+
}): CSSProperties;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/** The reveal fade, in milliseconds: parts fade in, and passing parts fade out, this fast. */
|
|
2
|
+
export const FADE_MS = 300;
|
|
3
|
+
/** How long a part takes to glide to the place a change of the slide pushed it to. */
|
|
4
|
+
export const GLIDE_MS = 300;
|
|
5
|
+
/**
|
|
6
|
+
* The parts that a change pushed to another place, with how far, so they can glide there instead
|
|
7
|
+
* of jumping. A part that just appeared fades in where it is, and a part that cannot be seen has
|
|
8
|
+
* nothing to show. A part inside one that glides only glides by what it moved within it, so the
|
|
9
|
+
* two do not add up to too much. `after` lists parts around a part before the part itself, as the
|
|
10
|
+
* document does.
|
|
11
|
+
*/
|
|
12
|
+
export function getGlides(before, after, threshold = 0.5) {
|
|
13
|
+
let glides = [];
|
|
14
|
+
let moved = new Map();
|
|
15
|
+
for (let [id, box] of after) {
|
|
16
|
+
let old = before.get(id);
|
|
17
|
+
if (!old || !old.shown || !box.shown)
|
|
18
|
+
continue;
|
|
19
|
+
let dx = old.x - box.x;
|
|
20
|
+
let dy = old.y - box.y;
|
|
21
|
+
let ancestor = box.parent;
|
|
22
|
+
while (ancestor && !moved.has(ancestor))
|
|
23
|
+
ancestor = after.get(ancestor)?.parent ?? null;
|
|
24
|
+
let carried = ancestor ? moved.get(ancestor) : { dx: 0, dy: 0 };
|
|
25
|
+
let own = { dx: dx - carried.dx, dy: dy - carried.dy };
|
|
26
|
+
if (Math.abs(own.dx) < threshold && Math.abs(own.dy) < threshold)
|
|
27
|
+
continue;
|
|
28
|
+
moved.set(id, { dx, dy });
|
|
29
|
+
glides.push({ id, ...own });
|
|
30
|
+
}
|
|
31
|
+
return glides;
|
|
32
|
+
}
|
|
33
|
+
/** Every part in the slide with its box. Sizes are layout sizes, without an effect's scale. */
|
|
34
|
+
export function measureParts(root) {
|
|
35
|
+
let origin = root.getBoundingClientRect();
|
|
36
|
+
let boxes = new Map();
|
|
37
|
+
for (let element of root.querySelectorAll("[data-part]")) {
|
|
38
|
+
let rect = element.getBoundingClientRect();
|
|
39
|
+
let parent = element.parentElement?.closest("[data-part]");
|
|
40
|
+
boxes.set(element.dataset.part, {
|
|
41
|
+
x: rect.left - origin.left,
|
|
42
|
+
y: rect.top - origin.top,
|
|
43
|
+
width: element.offsetWidth,
|
|
44
|
+
height: element.offsetHeight,
|
|
45
|
+
shown: !element.closest(".is-pending, .is-leaving"),
|
|
46
|
+
parent: parent && root.contains(parent) ? parent.dataset.part : null,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return boxes;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Lifts the parts that started to fade out out of the flow, onto the box they had before the
|
|
53
|
+
* change, so the part coming in their place takes it at once and nothing jumps when they go.
|
|
54
|
+
*/
|
|
55
|
+
export function pinLeaving(root, before) {
|
|
56
|
+
let origin = root.getBoundingClientRect();
|
|
57
|
+
for (let element of root.querySelectorAll(".is-leaving[data-part]")) {
|
|
58
|
+
if (element.dataset.pinned != null || element.parentElement?.closest(".is-leaving"))
|
|
59
|
+
continue;
|
|
60
|
+
let box = before.get(element.dataset.part);
|
|
61
|
+
if (!box || getComputedStyle(element).position === "absolute")
|
|
62
|
+
continue;
|
|
63
|
+
element.dataset.pinned = "";
|
|
64
|
+
Object.assign(element.style, {
|
|
65
|
+
position: "absolute",
|
|
66
|
+
margin: "0",
|
|
67
|
+
width: `${box.width}px`,
|
|
68
|
+
height: `${box.height}px`,
|
|
69
|
+
top: "0px",
|
|
70
|
+
left: "0px",
|
|
71
|
+
});
|
|
72
|
+
// Where top and left 0 put it depends on the positioned box around it, so measure and correct
|
|
73
|
+
let now = element.getBoundingClientRect();
|
|
74
|
+
element.style.top = `${box.y - (now.top - origin.top)}px`;
|
|
75
|
+
element.style.left = `${box.x - (now.left - origin.left)}px`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** Puts a part that came back while it was fading out into the flow again. */
|
|
79
|
+
export function unpinReturned(root) {
|
|
80
|
+
for (let element of root.querySelectorAll("[data-pinned]:not(.is-leaving)")) {
|
|
81
|
+
delete element.dataset.pinned;
|
|
82
|
+
for (let property of ["position", "margin", "width", "height", "top", "left"]) {
|
|
83
|
+
element.style.removeProperty(property);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** Starts the glides on the elements; `composite: "add"` keeps an effect's own move under them. */
|
|
88
|
+
export function runGlides(root, glides) {
|
|
89
|
+
for (let glide of glides) {
|
|
90
|
+
let element = root.querySelector(`[data-part="${CSS.escape(glide.id)}"]`);
|
|
91
|
+
if (typeof element?.animate !== "function")
|
|
92
|
+
continue;
|
|
93
|
+
element.animate([{ translate: `${glide.dx}px ${glide.dy}px` }, { translate: "0px 0px" }], {
|
|
94
|
+
duration: GLIDE_MS,
|
|
95
|
+
easing: "ease",
|
|
96
|
+
composite: "add",
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** Width to height from a canvas's `aspect`, e.g. `16/9`. */
|
|
101
|
+
export function aspectRatio(aspect) {
|
|
102
|
+
let [width, height] = (aspect ?? "16/9").split("/").map((value) => Number(value.trim()));
|
|
103
|
+
return width > 0 && height > 0 ? width / height : 16 / 9;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The inline style a part's effects and reveal delay give it. A move on a canvas item is in percent
|
|
107
|
+
* of the canvas (`cqi` is a percent of its width; the height is the width over the aspect), on any
|
|
108
|
+
* other part in the slide's text size. The transition lists the reveal fade too, since an inline
|
|
109
|
+
* transition replaces the stylesheet's.
|
|
110
|
+
*/
|
|
111
|
+
export function partStyle({ effect, delay, state, canvasAspect, }) {
|
|
112
|
+
let style = {};
|
|
113
|
+
let transitions = [];
|
|
114
|
+
if (effect) {
|
|
115
|
+
let x = canvasAspect != null ? `${effect.x}cqi` : `calc(${effect.x} * var(--ob-course-em))`;
|
|
116
|
+
let y = canvasAspect != null ? `calc(${effect.y}cqi / ${canvasAspect})` : `calc(${effect.y} * var(--ob-course-em))`;
|
|
117
|
+
style.translate = `${x} ${y}`;
|
|
118
|
+
style.scale = String(effect.scale);
|
|
119
|
+
// A filter, so the effect's opacity multiplies with the reveal fade instead of replacing it
|
|
120
|
+
style.filter = `opacity(${effect.opacity ?? 1})`;
|
|
121
|
+
let timing = `${effect.duration}ms ease ${effect.delay}ms`;
|
|
122
|
+
transitions.push(`translate ${timing}`, `scale ${timing}`, `filter ${timing}`);
|
|
123
|
+
}
|
|
124
|
+
let wait = state === "shown" ? (delay ?? 0) : 0;
|
|
125
|
+
if (wait > 0) {
|
|
126
|
+
// Only on the way in: a part that is hidden again goes at once
|
|
127
|
+
transitions.push(`opacity ${FADE_MS}ms ease ${wait}ms`, `visibility 0s linear ${wait}ms`);
|
|
128
|
+
style.animationDelay = `${wait}ms`;
|
|
129
|
+
}
|
|
130
|
+
else if (transitions.length > 0) {
|
|
131
|
+
transitions.push(`opacity ${FADE_MS}ms ease`);
|
|
132
|
+
}
|
|
133
|
+
if (transitions.length > 0)
|
|
134
|
+
style.transition = transitions.join(", ");
|
|
135
|
+
return style;
|
|
136
|
+
}
|