@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.
Files changed (96) hide show
  1. package/es/chrome/CategoryHeader.css +28 -0
  2. package/es/completion/CourseCompletion.css +53 -0
  3. package/es/completion/CourseCompletion.d.ts +32 -0
  4. package/es/completion/CourseCompletion.js +60 -0
  5. package/es/document/cues.d.ts +51 -6
  6. package/es/document/cues.js +117 -14
  7. package/es/document/effects.d.ts +30 -0
  8. package/es/document/effects.js +76 -0
  9. package/es/document/schema.d.ts +2722 -346
  10. package/es/document/schema.js +172 -5
  11. package/es/document/validate.d.ts +2 -1
  12. package/es/document/validate.js +83 -16
  13. package/es/index.d.ts +8 -3
  14. package/es/index.js +6 -2
  15. package/es/media/Media.css +16 -0
  16. package/es/media/icons.d.ts +1 -0
  17. package/es/media/icons.js +3 -0
  18. package/es/player/CoursePlayer.css +76 -0
  19. package/es/player/CoursePlayer.js +28 -13
  20. package/es/player/PlayerBars.d.ts +32 -0
  21. package/es/player/PlayerBars.js +14 -0
  22. package/es/player/useFullScreen.d.ts +17 -0
  23. package/es/player/useFullScreen.js +83 -0
  24. package/es/player/useMediaQuery.d.ts +7 -0
  25. package/es/player/useMediaQuery.js +16 -0
  26. package/es/steps/Blocks.d.ts +43 -3
  27. package/es/steps/Blocks.js +114 -26
  28. package/es/steps/Markdown.d.ts +7 -1
  29. package/es/steps/Markdown.js +31 -4
  30. package/es/steps/QuizStepView.d.ts +2 -1
  31. package/es/steps/QuizStepView.js +20 -10
  32. package/es/steps/RevealMotion.d.ts +29 -0
  33. package/es/steps/RevealMotion.js +55 -0
  34. package/es/steps/SlideStepView.d.ts +5 -3
  35. package/es/steps/SlideStepView.js +43 -10
  36. package/es/steps/StepBodyProps.d.ts +16 -1
  37. package/es/steps/StepView.css +390 -16
  38. package/es/steps/StepView.d.ts +36 -4
  39. package/es/steps/StepView.js +21 -5
  40. package/es/steps/motion.d.ts +59 -0
  41. package/es/steps/motion.js +136 -0
  42. package/es/transitions/Transitions.css +114 -0
  43. package/es/transitions/plan.d.ts +66 -0
  44. package/es/transitions/plan.js +185 -0
  45. package/es/transitions/playStepTransition.d.ts +23 -0
  46. package/es/transitions/playStepTransition.js +131 -0
  47. package/es/types.d.ts +16 -3
  48. package/package.json +4 -4
  49. package/src/chrome/CategoryHeader.css +28 -0
  50. package/src/completion/CourseCompletion.css +53 -0
  51. package/src/completion/CourseCompletion.test.tsx +45 -0
  52. package/src/completion/CourseCompletion.tsx +98 -0
  53. package/src/document/box.test.ts +234 -0
  54. package/src/document/cues.ts +143 -13
  55. package/src/document/document.test.ts +1 -1
  56. package/src/document/effects.ts +106 -0
  57. package/src/document/reveal.test.ts +263 -0
  58. package/src/document/schema.ts +203 -5
  59. package/src/document/validate.ts +88 -18
  60. package/src/index.ts +46 -1
  61. package/src/media/Media.css +16 -0
  62. package/src/media/icons.tsx +8 -0
  63. package/src/player/CoursePlayer.css +76 -0
  64. package/src/player/CoursePlayer.test.tsx +70 -6
  65. package/src/player/CoursePlayer.tsx +91 -60
  66. package/src/player/PlayerBars.tsx +106 -0
  67. package/src/player/fullScreen.test.tsx +70 -0
  68. package/src/player/useFullScreen.ts +91 -0
  69. package/src/player/useMediaQuery.ts +21 -0
  70. package/src/steps/Blocks.test.ts +34 -0
  71. package/src/steps/Blocks.tsx +219 -32
  72. package/src/steps/Box.test.tsx +95 -0
  73. package/src/steps/Markdown.test.tsx +46 -0
  74. package/src/steps/Markdown.tsx +42 -4
  75. package/src/steps/Presence.test.tsx +82 -0
  76. package/src/steps/QuizStepView.test.tsx +79 -0
  77. package/src/steps/QuizStepView.tsx +34 -12
  78. package/src/steps/RevealMotion.ts +66 -0
  79. package/src/steps/SlideStepView.tsx +74 -12
  80. package/src/steps/StepBodyProps.ts +16 -1
  81. package/src/steps/StepView.css +390 -16
  82. package/src/steps/StepView.test.tsx +157 -0
  83. package/src/steps/StepView.tsx +108 -19
  84. package/src/steps/motion.test.ts +98 -0
  85. package/src/steps/motion.ts +178 -0
  86. package/src/steps/visibility.test.ts +24 -0
  87. package/src/transitions/Transitions.css +114 -0
  88. package/src/transitions/plan.ts +258 -0
  89. package/src/transitions/playStepTransition.ts +162 -0
  90. package/src/transitions/transitions.test.ts +274 -0
  91. package/src/types.ts +16 -3
  92. package/es/Transitions.css +0 -55
  93. package/es/Transitions.d.ts +0 -10
  94. package/es/Transitions.js +0 -24
  95. package/src/Transitions.css +0 -55
  96. package/src/Transitions.ts +0 -35
@@ -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: clamp(1rem, 4cqi, 3rem);
32
+ padding: var(--ob-course-step-pad);
31
33
  }
32
34
 
33
35
  .ob-course-step--standalone {
@@ -36,13 +38,31 @@
36
38
 
37
39
  /* Blocks */
38
40
 
41
+ /*
42
+ * An editor's place to add a block (`renderInsert`): the node it draws is laid out as a block would
43
+ * be. The rules for a slide's first heading skip it, so a title looks the same while it is edited.
44
+ */
45
+ .ob-course-insert {
46
+ display: contents;
47
+ }
48
+
39
49
  .ob-course-slide {
40
50
  flex: 1;
41
51
  display: flex;
42
52
  flex-direction: column;
43
53
  position: relative;
44
- margin: calc(-1 * clamp(1rem, 4cqi, 3rem));
45
- padding: clamp(1rem, 4cqi, 3rem);
54
+ margin: calc(-1 * var(--ob-course-step-pad));
55
+ padding: var(--ob-course-step-pad);
56
+ }
57
+
58
+ .ob-course-slide--background {
59
+ isolation: isolate;
60
+ }
61
+
62
+ .ob-course-slide__background {
63
+ position: absolute;
64
+ inset: 0;
65
+ z-index: -1;
46
66
  background-size: cover;
47
67
  background-position: center;
48
68
  }
@@ -53,7 +73,8 @@
53
73
  gap: 0.9em;
54
74
  width: 100%;
55
75
  max-width: 70rem;
56
- margin-inline: auto;
76
+ /* In the middle of the step while it fits; auto margins give way when it has to scroll */
77
+ margin: auto;
57
78
  }
58
79
 
59
80
  .ob-course-slide--centered {
@@ -69,7 +90,20 @@
69
90
  }
70
91
  }
71
92
 
72
- .ob-course-slide--background .ob-course-slide__content {
93
+ /* The doubled class lets a width set on the slide win over a layout's own. */
94
+ .ob-course-slide.ob-course-slide--narrow .ob-course-slide__content {
95
+ max-width: 36rem;
96
+ }
97
+
98
+ .ob-course-slide.ob-course-slide--medium .ob-course-slide__content {
99
+ max-width: 52rem;
100
+ }
101
+
102
+ .ob-course-slide.ob-course-slide--wide .ob-course-slide__content {
103
+ max-width: 70rem;
104
+ }
105
+
106
+ .ob-course-slide--background:not(.ob-course-slide--bare) .ob-course-slide__content {
73
107
  padding: clamp(0.75rem, 3cqi, 2rem);
74
108
  border-radius: var(--ds-border-radius-lg, 8px);
75
109
  background: color-mix(in srgb, var(--ds-color-neutral-background-default) 88%, transparent);
@@ -90,7 +124,7 @@
90
124
  }
91
125
 
92
126
  /* The first heading is the title whatever its level, in the company's colour. */
93
- .ob-course-slide__content > .ob-course-block--heading:first-child {
127
+ .ob-course-slide__content > .ob-course-block--heading:nth-child(1 of :not(.ob-course-insert)) {
94
128
  font-size: clamp(2em, 1.2em + 4cqi, 3.6em);
95
129
  color: var(--ds-color-brand-text-default);
96
130
  }
@@ -105,14 +139,13 @@
105
139
  }
106
140
 
107
141
  .ob-course-slide--title.ob-course-slide--background {
108
- isolation: isolate;
109
142
  color: white;
110
143
 
111
- &::before {
144
+ /* The shade belongs to the picture, so it moves with the background in a transition */
145
+ .ob-course-slide__background::after {
112
146
  content: "";
113
147
  position: absolute;
114
148
  inset: 0;
115
- z-index: -1;
116
149
  background: rgb(0 0 0 / 0.4);
117
150
  }
118
151
 
@@ -123,7 +156,7 @@
123
156
  box-shadow: none;
124
157
  text-shadow: 0 2px 12px rgb(0 0 0 / 0.6);
125
158
 
126
- > .ob-course-block--heading:first-child {
159
+ > .ob-course-block--heading:nth-child(1 of :not(.ob-course-insert)) {
127
160
  color: inherit;
128
161
  }
129
162
  }
@@ -133,14 +166,91 @@
133
166
  }
134
167
  }
135
168
 
169
+ /*
170
+ * A banner: the image runs from edge to edge in its own proportions, between two coloured bars,
171
+ * with the words on top of it. A theme sets the bars with --ob-course-banner-border.
172
+ */
173
+ .ob-course-slide--banner {
174
+ padding-inline: 0;
175
+
176
+ .ob-course-slide__narration {
177
+ padding-inline: var(--ob-course-step-pad);
178
+ }
179
+ }
180
+
181
+ .ob-course-banner {
182
+ display: flex;
183
+ flex-direction: column;
184
+ margin-block: auto;
185
+
186
+ &::before,
187
+ &::after {
188
+ content: "";
189
+ flex: none;
190
+ height: 0.75em;
191
+ background: var(--ob-course-banner-border, linear-gradient(45deg, #002878, #002878 30%, #00722a 70%, #00722a));
192
+ }
193
+ }
194
+
195
+ .ob-course-banner__stage {
196
+ display: grid;
197
+
198
+ > * {
199
+ grid-area: 1 / 1;
200
+ }
201
+ }
202
+
203
+ .ob-course-banner__image {
204
+ display: block;
205
+ width: 100%;
206
+ height: 100%;
207
+ min-height: 8em;
208
+ object-fit: cover;
209
+ }
210
+
211
+ .ob-course-banner .ob-course-slide__content {
212
+ z-index: 1;
213
+ justify-content: center;
214
+ align-items: center;
215
+ max-width: none;
216
+ margin: 0;
217
+ padding: 1em clamp(1rem, 4cqi, 3rem);
218
+ background: rgb(0 0 0 / 0.2);
219
+ color: white;
220
+ text-align: center;
221
+ text-shadow: 0.05em 0.05em rgb(0 0 0 / 0.5);
222
+
223
+ > .ob-course-block--heading:nth-child(1 of :not(.ob-course-insert)) {
224
+ font-size: clamp(2em, 1.2em + 4cqi, 3.6em);
225
+ }
226
+
227
+ .ob-course-block--text {
228
+ font-size: 1.2em;
229
+ }
230
+ }
231
+
136
232
  .ob-course-slide__narration {
137
233
  width: 100%;
138
234
  max-width: 70rem;
139
- margin: auto auto 0;
235
+ margin-inline: auto;
140
236
  padding-top: 1em;
141
237
  font-size: 1rem;
142
238
  }
143
239
 
240
+ /*
241
+ * Over a background image the controls get the same surface as the content, so the button and
242
+ * the time can be read on a light picture and on a dark one.
243
+ */
244
+ .ob-course-slide--background .ob-course-slide__narration {
245
+ margin-top: 1em;
246
+ padding: 0 var(--ds-size-3, 0.75rem);
247
+ border-radius: var(--ds-border-radius-lg, 8px);
248
+ background: color-mix(in srgb, var(--ds-color-neutral-background-default) 88%, transparent);
249
+ box-shadow: var(--ds-shadow-md);
250
+ color: var(--ds-color-neutral-text-default);
251
+ text-shadow: none;
252
+ }
253
+
144
254
  /* Leaves room for the subtitle above the narration controls. */
145
255
  .ob-course-slide:has(.ob-course-slide__narration) > .ob-course-subtitles {
146
256
  inset-block-end: 4.5rem;
@@ -156,6 +266,81 @@
156
266
  }
157
267
  }
158
268
 
269
+ /*
270
+ * The unit an effect's move is given in: the slide's own text size, computed where it is declared
271
+ * so a move is the same on a large heading as on a line of text.
272
+ */
273
+ @property --ob-course-em {
274
+ syntax: "<length>";
275
+ inherits: true;
276
+ initial-value: 16px;
277
+ }
278
+
279
+ .ob-course-slide {
280
+ --ob-course-em: 1em;
281
+ }
282
+
283
+ /*
284
+ * An effect's scale works from where the text starts, so a left-aligned heading shrinks towards
285
+ * its own edge instead of drifting inwards. Parts that stand in the middle - on a centred, title or
286
+ * banner slide, images, columns and canvas items - scale from their centre, the default.
287
+ */
288
+ .ob-course-slide
289
+ :is(
290
+ .ob-course-block--heading,
291
+ .ob-course-block--text,
292
+ .ob-course-block--list,
293
+ .ob-course-block--quote,
294
+ .ob-course-block--callout,
295
+ .ob-course-block--box,
296
+ .ob-course-block--video-link,
297
+ .ob-course-list-item
298
+ ) {
299
+ transform-origin: left center;
300
+ }
301
+
302
+ .ob-course-slide:is(.ob-course-slide--centered, .ob-course-slide--title, .ob-course-slide--banner)
303
+ :is(
304
+ .ob-course-block--heading,
305
+ .ob-course-block--text,
306
+ .ob-course-block--list,
307
+ .ob-course-block--quote,
308
+ .ob-course-block--callout,
309
+ .ob-course-block--box,
310
+ .ob-course-block--video-link,
311
+ .ob-course-list-item
312
+ ) {
313
+ transform-origin: center;
314
+ }
315
+
316
+ /* A passing part that came into the page after the slide was drawn */
317
+ .ob-course-block.is-entering,
318
+ .ob-course-list-item.is-entering,
319
+ .ob-course-canvas__item.is-entering {
320
+ animation: ob-course-part-in 0.3s ease backwards;
321
+ }
322
+
323
+ /* A passing part on its way out: the slide has lifted it out of the flow over its last place */
324
+ .ob-course-block.is-leaving,
325
+ .ob-course-list-item.is-leaving,
326
+ .ob-course-canvas__item.is-leaving {
327
+ opacity: 0;
328
+ pointer-events: none;
329
+ }
330
+
331
+ @keyframes ob-course-part-in {
332
+ from {
333
+ opacity: 0;
334
+ }
335
+ }
336
+
337
+ @media (prefers-reduced-motion: reduce) {
338
+ [data-part] {
339
+ transition: none !important;
340
+ animation: none !important;
341
+ }
342
+ }
343
+
159
344
  .ob-course-list-item {
160
345
  transition: opacity 0.3s ease;
161
346
 
@@ -169,6 +354,22 @@
169
354
  }
170
355
  }
171
356
 
357
+ .ob-course-look--caps {
358
+ text-transform: uppercase;
359
+ letter-spacing: 0.02em;
360
+ }
361
+
362
+ .ob-course-look--shadow {
363
+ /* Hard, not blurred: the look the courses have used on titles */
364
+ text-shadow: 0.05em 0.05em 0 rgb(0 0 0 / 0.5);
365
+ }
366
+
367
+ .ob-course-sublist {
368
+ margin: 0.4em 0 0;
369
+ padding-inline-start: 1.4em;
370
+ font-size: 0.9em;
371
+ }
372
+
172
373
  .ob-course-heading--1,
173
374
  .ob-course-heading--2,
174
375
  .ob-course-heading--3 {
@@ -199,11 +400,28 @@
199
400
  margin-top: 0.75em;
200
401
  }
201
402
 
403
+ /* A link looks like one whatever the page does with links */
202
404
  a {
203
405
  color: var(--ds-color-brand-text-default);
406
+ text-decoration: underline;
407
+ text-decoration-thickness: max(1px, 0.06em);
408
+ text-underline-offset: 0.15em;
409
+
410
+ &:hover {
411
+ text-decoration-thickness: max(2px, 0.12em);
412
+ }
204
413
  }
205
414
  }
206
415
 
416
+ /* `data-color` picks the colour scale, as on a callout. */
417
+ .ob-course-tone {
418
+ color: var(--ds-color-text-subtle);
419
+ }
420
+
421
+ .ob-course-markdown big {
422
+ font-size: 1.25em;
423
+ }
424
+
207
425
  .ob-course-markdown--inline {
208
426
  display: inline;
209
427
  }
@@ -255,8 +473,11 @@
255
473
  object-fit: contain;
256
474
  }
257
475
 
258
- /* `data-color` picks the Designsystemet colour scale the tokens below resolve to. */
259
- .ob-course-block--callout {
476
+ /*
477
+ * A callout or a box. `data-color` picks the Designsystemet colour scale the tokens below resolve
478
+ * to; every theme maps `brand` to its own scale the way it maps the severity colours.
479
+ */
480
+ .ob-course-surface {
260
481
  padding: 0.9em 1.1em;
261
482
  border: var(--ds-border-width-default, 1px) solid var(--ds-color-border-subtle);
262
483
  border-inline-start: 0.35em solid var(--ds-color-base-default);
@@ -270,6 +491,51 @@
270
491
  }
271
492
  }
272
493
 
494
+ /*
495
+ * The tone's base colour with its contrast colour on it, the pair the theme guarantees can be read.
496
+ * What has a colour of its own inside takes the contrast colour instead, since its own would vanish
497
+ * on a surface of the same scale.
498
+ */
499
+ .ob-course-surface--filled {
500
+ border-color: var(--ds-color-base-default);
501
+ background: var(--ds-color-base-default);
502
+ color: var(--ds-color-base-contrast-default);
503
+ /* A title page's shadow is for words on a picture, not on a solid colour */
504
+ text-shadow: none;
505
+
506
+ .ob-course-tone {
507
+ color: inherit;
508
+ font-weight: 600;
509
+ }
510
+
511
+ .ob-course-block--quote blockquote {
512
+ border-inline-start-color: currentColor;
513
+ }
514
+
515
+ figcaption,
516
+ .ob-course-block--quote figcaption,
517
+ .ob-course-block--image figcaption {
518
+ color: var(--ds-color-base-contrast-subtle);
519
+ }
520
+
521
+ /* The video link's outlined button would be the surface's colour on itself */
522
+ .ob-course-block--video-link .ds-button {
523
+ --dsc-button-background: var(--ds-color-surface-default);
524
+ --dsc-button-background--hover: var(--ds-color-surface-hover);
525
+ --dsc-button-background--active: var(--ds-color-surface-active);
526
+ --dsc-button-border-color: transparent;
527
+ --dsc-button-color: var(--ds-color-text-default);
528
+ }
529
+ }
530
+
531
+ /* The parts of a box stand like the parts of a column, and reveal the same way. */
532
+ .ob-course-block--box {
533
+ display: flex;
534
+ flex-direction: column;
535
+ gap: 0.9em;
536
+ min-width: 0;
537
+ }
538
+
273
539
  .ob-course-block--quote {
274
540
  blockquote {
275
541
  margin: 0;
@@ -309,6 +575,59 @@
309
575
  gap: 0.9em;
310
576
  }
311
577
 
578
+ /*
579
+ * A canvas keeps its proportions and everything on it scales with its width, the text included,
580
+ * so the parts stay where they were put. Below 40rem it stops shrinking and scrolls sideways
581
+ * instead, because the text would be too small to read. Light whatever the page is, like paper.
582
+ */
583
+ .ob-course-block--canvas {
584
+ overflow-x: auto;
585
+ }
586
+
587
+ .ob-course-canvas {
588
+ position: relative;
589
+ container-type: inline-size;
590
+ width: 100%;
591
+ min-width: 40rem;
592
+ overflow: hidden;
593
+ border-radius: var(--ds-border-radius-md, 4px);
594
+ background: white;
595
+ color: #1e2b3c;
596
+ text-align: start;
597
+ }
598
+
599
+ .ob-course-canvas__item {
600
+ position: absolute;
601
+ margin: 0;
602
+ transition: opacity 0.3s ease;
603
+
604
+ &.is-pending {
605
+ visibility: hidden;
606
+ opacity: 0;
607
+ }
608
+ }
609
+
610
+ .ob-course-canvas__image {
611
+ max-width: none;
612
+ object-fit: contain;
613
+ }
614
+
615
+ .ob-course-canvas__text {
616
+ font-size: calc(1.7cqi * var(--ob-course-canvas-size, 1));
617
+ line-height: 1.35;
618
+ }
619
+
620
+ .ob-course-canvas__text--solid,
621
+ .ob-course-canvas__text--frame {
622
+ padding: 0.2em 0.4em;
623
+ background: white;
624
+ }
625
+
626
+ .ob-course-canvas__text--frame {
627
+ padding: 0.8em;
628
+ border: 0.3em solid var(--ds-color-border-strong);
629
+ }
630
+
312
631
  .ob-course-video-dialog {
313
632
  width: min(64rem, 100vw - 2rem);
314
633
  max-width: none;
@@ -316,19 +635,40 @@
316
635
 
317
636
  /* Video, document and quiz steps */
318
637
 
638
+ /*
639
+ * A video is as large as fits: the step's width, or the width its height allows, so the whole
640
+ * picture and its controls are in view without scrolling. The step is a size container for that.
641
+ */
642
+ .ob-course-step__body:has(> .ob-course-video-step, > .ob-course-video-stage) {
643
+ flex: 1 1 0;
644
+ min-height: 0;
645
+ }
646
+
319
647
  .ob-course-video-step {
648
+ flex: 1 1 0;
649
+ display: flex;
650
+ align-items: center;
651
+ justify-content: center;
652
+ container-type: size;
320
653
  width: 100%;
321
654
  max-width: 80rem;
322
- margin: auto;
655
+ min-height: 14rem;
656
+ margin-inline: auto;
657
+
658
+ /* 3.5rem: the row of controls under the picture */
659
+ > .ob-course-video {
660
+ width: min(100%, (100cqb - 3.5rem) * 16 / 9);
661
+ }
323
662
  }
324
663
 
325
664
  /* A video over a background image fills the step the way a slide's background does. */
326
665
  .ob-course-video-stage {
327
666
  flex: 1;
667
+ min-height: 0;
328
668
  display: flex;
329
669
  flex-direction: column;
330
- margin: calc(-1 * clamp(1rem, 4cqi, 3rem));
331
- padding: clamp(1rem, 4cqi, 3rem);
670
+ margin: calc(-1 * var(--ob-course-step-pad));
671
+ padding: var(--ob-course-step-pad);
332
672
  background-size: cover;
333
673
  background-position: center;
334
674
 
@@ -378,3 +718,37 @@
378
718
  .ob-course-slide [data-part] {
379
719
  scroll-margin-block: var(--ds-size-4, 1rem);
380
720
  }
721
+
722
+ /*
723
+ * A phone on its side: little height. The text scales with the height as well as the width, the room
724
+ * around it shrinks, and the narration controls and subtitles take less of the slide.
725
+ */
726
+ @media (orientation: landscape) and (max-height: 500px) {
727
+ .ob-course-step__body {
728
+ --ob-course-step-pad: clamp(0.5rem, 2cqi, 1rem);
729
+ font-size: min(clamp(1rem, 0.9rem + 0.8cqi, 1.6rem), max(0.8125rem, 4.2vh));
730
+ font-size: min(clamp(1rem, 0.9rem + 0.8cqi, 1.6rem), max(0.8125rem, 4.2dvh));
731
+ line-height: 1.4;
732
+ }
733
+
734
+ .ob-course-slide__content {
735
+ gap: 0.6em;
736
+ }
737
+
738
+ .ob-course-slide--title .ob-course-slide__content > .ob-course-block--heading:nth-child(1 of :not(.ob-course-insert)),
739
+ .ob-course-banner .ob-course-slide__content > .ob-course-block--heading:nth-child(1 of :not(.ob-course-insert)) {
740
+ font-size: clamp(1.5em, 1em + 3cqi, 2.4em);
741
+ }
742
+
743
+ .ob-course-slide__narration {
744
+ padding-top: 0.25em;
745
+ }
746
+
747
+ .ob-course-slide--background .ob-course-slide__narration {
748
+ margin-top: 0.4em;
749
+ }
750
+
751
+ .ob-course-slide:has(.ob-course-slide__narration) > .ob-course-subtitles {
752
+ inset-block-end: 3rem;
753
+ }
754
+ }
@@ -34,4 +34,161 @@ 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
+ });
78
+
79
+ describe("revealAll, for an editor", () => {
80
+ let timed: Step = {
81
+ schemaVersion: 2,
82
+ type: "slide",
83
+ blocks: [
84
+ { id: "h", type: "heading", text: "Shown" },
85
+ { id: "t", type: "text", text: "On Next", reveal: "step" },
86
+ { id: "c", type: "text", text: "Passing", revealAt: "c1", hideAt: "c2" },
87
+ ],
88
+ };
89
+
90
+ it("hides the parts that wait, as the player does, when it is off", () => {
91
+ let { container } = render(<StepView step={timed} resolveAsset={resolveAsset} stepsShown={0} />);
92
+
93
+ expect(container.querySelector('[data-part="t"]')?.classList.contains("is-pending")).toBe(true);
94
+ expect(container.querySelector('[data-part="c"]')).toBeNull();
95
+ expect(container.querySelector(".is-unrevealed")).toBeNull();
96
+ });
97
+
98
+ it("draws every part and marks the ones that would wait", () => {
99
+ let { container } = render(<StepView step={timed} resolveAsset={resolveAsset} stepsShown={0} revealAll />);
100
+
101
+ let waiting = container.querySelector('[data-part="t"]');
102
+ expect(waiting?.classList.contains("is-unrevealed")).toBe(true);
103
+ expect(waiting?.classList.contains("is-pending")).toBe(false);
104
+ expect(waiting?.hasAttribute("inert")).toBe(false);
105
+ expect(container.querySelector('[data-part="c"]')?.classList.contains("is-unrevealed")).toBe(true);
106
+ expect(container.querySelector('[data-part="h"]')?.classList.contains("is-unrevealed")).toBe(false);
107
+ });
108
+ });
109
+
110
+ describe("renderInsert, for an editor", () => {
111
+ let nested: Step = {
112
+ schemaVersion: 2,
113
+ type: "slide",
114
+ blocks: [
115
+ { id: "h", type: "heading", text: "Title" },
116
+ { id: "e", type: "effect", target: "h", scale: 1.2 },
117
+ {
118
+ id: "cols",
119
+ type: "columns",
120
+ columns: [
121
+ { id: "c1", blocks: [{ id: "t", type: "text", text: "Left" }] },
122
+ { id: "c2", blocks: [] },
123
+ ],
124
+ },
125
+ { id: "b", type: "box", blocks: [] },
126
+ ],
127
+ };
128
+
129
+ function places(step: Step) {
130
+ let { container } = render(
131
+ <StepView
132
+ step={step}
133
+ resolveAsset={resolveAsset}
134
+ renderInsert={({ container, index }) => (
135
+ <i data-insert={`${container.kind}${"id" in container ? `:${container.id}` : ""}@${index}`} />
136
+ )}
137
+ />,
138
+ );
139
+ return [...container.querySelectorAll("[data-insert]")].map((element) => element.getAttribute("data-insert"));
140
+ }
141
+
142
+ it("draws a place before every drawn block and at the end of each container, in reading order", () => {
143
+ expect(places(nested)).toEqual([
144
+ "slide@0",
145
+ "slide@2",
146
+ "column:c1@0",
147
+ "column:c1@1",
148
+ "column:c2@0",
149
+ "slide@3",
150
+ "box:b@0",
151
+ "slide@4",
152
+ ]);
153
+ });
154
+
155
+ it("draws nothing without it", () => {
156
+ let { container } = render(<StepView step={nested} resolveAsset={resolveAsset} />);
157
+ expect(container.querySelector("[data-insert]")).toBeNull();
158
+ });
159
+ });
160
+
161
+ describe("courseChrome, for an editor", () => {
162
+ it("draws the player's bars around the step, inert and hidden from screen readers", () => {
163
+ let { container } = render(
164
+ <StepView step={slide} resolveAsset={resolveAsset} courseChrome={{ title: "Safety", position: 2, count: 5 }} />,
165
+ );
166
+
167
+ let player = container.querySelector(".ob-course-player")!;
168
+ let header = player.querySelector(":scope > .ob-course-player__header")!;
169
+ let controls = player.querySelector(":scope > .ob-course-player__controls")!;
170
+ expect(header.textContent).toContain("Safety");
171
+ expect(header.hasAttribute("inert")).toBe(true);
172
+ expect(header.getAttribute("aria-hidden")).toBe("true");
173
+ expect(controls.hasAttribute("inert")).toBe(true);
174
+ expect(controls.textContent).toContain("2 / 5");
175
+ expect(player.querySelector(":scope > .ob-course-step [data-part='h']")).not.toBeNull();
176
+ expect(player.querySelector(".ob-course-step--standalone")).toBeNull();
177
+ });
178
+
179
+ it("says Complete on the last step and takes the slim size when compact", () => {
180
+ let { container } = render(
181
+ <StepView
182
+ step={slide}
183
+ resolveAsset={resolveAsset}
184
+ courseChrome={{ title: "Safety", position: 5, count: 5, compact: true }}
185
+ />,
186
+ );
187
+
188
+ let player = container.querySelector(".ob-course-player")!;
189
+ expect(player.classList.contains("is-compact")).toBe(true);
190
+ expect(player.querySelector(".ob-course-player__controls")?.textContent).toContain("Complete");
191
+ expect(player.querySelector(".ob-course-player__header")?.getAttribute("data-size")).toBe("sm");
192
+ });
193
+ });
37
194
  });