@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/src/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
|
+
}
|
|
@@ -34,4 +34,45 @@ describe("StepView", () => {
|
|
|
34
34
|
|
|
35
35
|
expect(container.querySelector(".ob-course-category-header__subtitle")).toBeNull();
|
|
36
36
|
});
|
|
37
|
+
|
|
38
|
+
it("keeps a list item's text inline, so the bullet stays on the text's line in every browser", () => {
|
|
39
|
+
let { container } = render(
|
|
40
|
+
<StepView
|
|
41
|
+
step={{
|
|
42
|
+
...slide,
|
|
43
|
+
blocks: [
|
|
44
|
+
{
|
|
45
|
+
id: "l",
|
|
46
|
+
type: "list",
|
|
47
|
+
ordered: true,
|
|
48
|
+
items: [
|
|
49
|
+
{ id: "i1", text: "Hjelm med **stropp** og [lenke](https://example.com)" },
|
|
50
|
+
{ id: "i2", text: "Under", indent: 1 },
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
}}
|
|
55
|
+
resolveAsset={resolveAsset}
|
|
56
|
+
/>,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
let item = container.querySelector('[data-part="i1"]')!;
|
|
60
|
+
let text = item.firstElementChild!;
|
|
61
|
+
expect(text.tagName).toBe("SPAN");
|
|
62
|
+
expect(text.querySelector("p, div")).toBeNull();
|
|
63
|
+
expect(text.querySelector("strong")).not.toBeNull();
|
|
64
|
+
expect(text.querySelector("a")).toHaveAttribute("target", "_blank");
|
|
65
|
+
// The sub-point is a list of its own after the text, not before it
|
|
66
|
+
expect(text.nextElementSibling?.matches(".ob-course-sublist")).toBe(true);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("draws a slide's background as a layer of its own, apart from the content", () => {
|
|
70
|
+
let { container } = render(
|
|
71
|
+
<StepView step={{ ...slide, background: "/media/course/bg.jpg" }} resolveAsset={resolveAsset} />,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
let layer = container.querySelector<HTMLElement>(".ob-course-slide > .ob-course-slide__background");
|
|
75
|
+
expect(layer?.style.backgroundImage).toContain("/media/course/bg.jpg");
|
|
76
|
+
expect(layer?.contains(container.querySelector(".ob-course-slide__content"))).toBe(false);
|
|
77
|
+
});
|
|
37
78
|
});
|
package/src/steps/StepView.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Alert } from "@digdir/designsystemet-react";
|
|
2
2
|
import { type ReactNode, useLayoutEffect, useState } from "react";
|
|
3
3
|
import { CategoryHeader } from "../chrome/CategoryHeader";
|
|
4
|
+
import type { RevealNavigation } from "../document/cues";
|
|
4
5
|
import type { Step } from "../document/schema";
|
|
5
6
|
import { getLocalizedString } from "../i18n";
|
|
6
7
|
import type { PlayerBranding, PlayerCategory, PlayerMode, QuizAdapter, ResolveAsset } from "../types";
|
|
@@ -68,8 +69,13 @@ export interface StepViewProps {
|
|
|
68
69
|
quiz?: QuizAdapter;
|
|
69
70
|
/** The slide the step belongs to, passed to the quiz adapter. */
|
|
70
71
|
slideId?: number;
|
|
71
|
-
/** How many `reveal: "step"` parts
|
|
72
|
+
/** How many `reveal: "step"` parts count as pressed. Every part is shown when left out. */
|
|
72
73
|
stepsShown?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Where Next and Back would take a slide from `stepsShown`, skipping presses that show nothing
|
|
76
|
+
* new, and how many presses show something: for a stepper that counts the way the player does.
|
|
77
|
+
*/
|
|
78
|
+
onRevealNavigation?(navigation: RevealNavigation): void;
|
|
73
79
|
/** The band above the step naming its part of the course, as the player shows it. None when left out. */
|
|
74
80
|
category?: PlayerCategory | null;
|
|
75
81
|
/**
|
|
@@ -89,6 +95,7 @@ export function StepView({
|
|
|
89
95
|
stepsShown,
|
|
90
96
|
category,
|
|
91
97
|
branding,
|
|
98
|
+
onRevealNavigation,
|
|
92
99
|
}: StepViewProps) {
|
|
93
100
|
let [subtitles, setSubtitles] = useState(true);
|
|
94
101
|
|
|
@@ -105,6 +112,7 @@ export function StepView({
|
|
|
105
112
|
subtitles={subtitles}
|
|
106
113
|
onSubtitlesChange={setSubtitles}
|
|
107
114
|
onDoneChange={ignore}
|
|
115
|
+
onRevealNavigation={onRevealNavigation}
|
|
108
116
|
/>
|
|
109
117
|
</StepFrame>
|
|
110
118
|
</div>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { aspectRatio, getGlides, type PartBox, partStyle } from "./motion";
|
|
3
|
+
|
|
4
|
+
function box(x: number, y: number, extra: Partial<PartBox> = {}): PartBox {
|
|
5
|
+
return { x, y, width: 100, height: 20, shown: true, parent: null, ...extra };
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
describe("getGlides", () => {
|
|
9
|
+
it("glides the parts that were pushed, from where they were", () => {
|
|
10
|
+
let before = new Map([
|
|
11
|
+
["h", box(0, 0)],
|
|
12
|
+
["t", box(0, 30)],
|
|
13
|
+
]);
|
|
14
|
+
let after = new Map([
|
|
15
|
+
["h", box(0, 0)],
|
|
16
|
+
["new", box(0, 30)],
|
|
17
|
+
["t", box(0, 60)],
|
|
18
|
+
]);
|
|
19
|
+
expect(getGlides(before, after)).toEqual([{ id: "t", dx: 0, dy: -30 }]);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("leaves out parts that just appeared, cannot be seen, or barely moved", () => {
|
|
23
|
+
let before = new Map([
|
|
24
|
+
["a", box(0, 0, { shown: false })],
|
|
25
|
+
["b", box(0, 10)],
|
|
26
|
+
["c", box(0, 20)],
|
|
27
|
+
]);
|
|
28
|
+
let after = new Map([
|
|
29
|
+
["a", box(0, 40)],
|
|
30
|
+
["b", box(0, 50, { shown: false })],
|
|
31
|
+
["c", box(0, 20.3)],
|
|
32
|
+
]);
|
|
33
|
+
expect(getGlides(before, after)).toEqual([]);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("glides a part inside a gliding one only by what it moved within it", () => {
|
|
37
|
+
let before = new Map([
|
|
38
|
+
["l", box(0, 0)],
|
|
39
|
+
["i1", box(10, 0, { parent: "l" })],
|
|
40
|
+
["i2", box(10, 20, { parent: "l" })],
|
|
41
|
+
]);
|
|
42
|
+
let after = new Map([
|
|
43
|
+
["l", box(0, 50)],
|
|
44
|
+
["i0", box(10, 50, { parent: "l" })],
|
|
45
|
+
["i1", box(10, 70, { parent: "l" })],
|
|
46
|
+
["i2", box(10, 90, { parent: "l" })],
|
|
47
|
+
]);
|
|
48
|
+
expect(getGlides(before, after)).toEqual([
|
|
49
|
+
{ id: "l", dx: 0, dy: -50 },
|
|
50
|
+
{ id: "i1", dx: 0, dy: -20 },
|
|
51
|
+
{ id: "i2", dx: 0, dy: -20 },
|
|
52
|
+
]);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("measures a nested part against the nearest part around it that glides", () => {
|
|
56
|
+
let before = new Map([
|
|
57
|
+
["cols", box(0, 0)],
|
|
58
|
+
["left", box(0, 0, { parent: "cols" })],
|
|
59
|
+
["t", box(0, 0, { parent: "left" })],
|
|
60
|
+
]);
|
|
61
|
+
let after = new Map([
|
|
62
|
+
["cols", box(0, 40)],
|
|
63
|
+
["left", box(0, 40, { parent: "cols" })],
|
|
64
|
+
["t", box(0, 40, { parent: "left" })],
|
|
65
|
+
]);
|
|
66
|
+
expect(getGlides(before, after)).toEqual([{ id: "cols", dx: 0, dy: -40 }]);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe("partStyle", () => {
|
|
71
|
+
let effect = { x: 2, y: -1, scale: 0.5, opacity: 0.4, delay: 100, duration: 600 };
|
|
72
|
+
|
|
73
|
+
it("moves a part in the slide's text size, with the effect's timing", () => {
|
|
74
|
+
let style = partStyle({ effect, state: "shown" });
|
|
75
|
+
expect(style.translate).toBe("calc(2 * var(--ob-course-em)) calc(-1 * var(--ob-course-em))");
|
|
76
|
+
expect(style.scale).toBe("0.5");
|
|
77
|
+
expect(style.filter).toBe("opacity(0.4)");
|
|
78
|
+
expect(style.transition).toBe(
|
|
79
|
+
"translate 600ms ease 100ms, scale 600ms ease 100ms, filter 600ms ease 100ms, opacity 300ms ease",
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("moves a canvas item in percent of the canvas", () => {
|
|
84
|
+
let style = partStyle({ effect, state: "shown", canvasAspect: 2 });
|
|
85
|
+
expect(style.translate).toBe("2cqi calc(-1cqi / 2)");
|
|
86
|
+
expect(aspectRatio("4 / 3")).toBeCloseTo(4 / 3);
|
|
87
|
+
expect(aspectRatio(undefined)).toBeCloseTo(16 / 9);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("holds a delayed part back on the way in only", () => {
|
|
91
|
+
expect(partStyle({ delay: 500, state: "shown" })).toEqual({
|
|
92
|
+
transition: "opacity 300ms ease 500ms, visibility 0s linear 500ms",
|
|
93
|
+
animationDelay: "500ms",
|
|
94
|
+
});
|
|
95
|
+
expect(partStyle({ delay: 500, state: "pending" })).toEqual({});
|
|
96
|
+
expect(partStyle({ state: "shown" })).toEqual({});
|
|
97
|
+
});
|
|
98
|
+
});
|