@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
+ }
@@ -1,8 +1,10 @@
1
1
  import { type ReactNode } from "react";
2
+ import type { RevealNavigation } from "../document/cues";
2
3
  import type { Step } from "../document/schema";
3
- import type { PlayerBranding, PlayerCategory, PlayerMode, QuizAdapter, ResolveAsset } from "../types";
4
+ import type { PlayerBranding, PlayerCategory, PlayerLanguage, PlayerMode, QuizAdapter, ResolveAsset } from "../types";
4
5
  import type { StepBodyProps } from "./StepBodyProps";
5
6
  import "./StepView.css";
7
+ import "../player/CoursePlayer.css";
6
8
  /** Picks the view for a step's type. A missing document is shown as not available, and counts as done. */
7
9
  export declare function StepBody({ step, ...props }: StepBodyProps & {
8
10
  step: Step | null;
@@ -24,8 +26,13 @@ export interface StepViewProps {
24
26
  quiz?: QuizAdapter;
25
27
  /** The slide the step belongs to, passed to the quiz adapter. */
26
28
  slideId?: number;
27
- /** How many `reveal: "step"` parts to show. Every part is shown when left out. */
29
+ /** How many `reveal: "step"` parts count as pressed. Every part is shown when left out. */
28
30
  stepsShown?: number;
31
+ /**
32
+ * Where Next and Back would take a slide from `stepsShown`, skipping presses that show nothing
33
+ * new, and how many presses show something: for a stepper that counts the way the player does.
34
+ */
35
+ onRevealNavigation?(navigation: RevealNavigation): void;
29
36
  /** The band above the step naming its part of the course, as the player shows it. None when left out. */
30
37
  category?: PlayerCategory | null;
31
38
  /**
@@ -33,6 +40,31 @@ export interface StepViewProps {
33
40
  * four product logos; given without a logo, the company's name.
34
41
  */
35
42
  branding?: PlayerBranding | null;
43
+ /**
44
+ * For an editor: draws every part of a slide whatever its timing, without effects, and marks the
45
+ * parts that would not be shown yet with `is-unrevealed`. Off (the default) it is the player.
46
+ */
47
+ revealAll?: boolean;
48
+ /** For an editor: a node drawn at each place on a slide where a block can be added. */
49
+ renderInsert?: StepBodyProps["renderInsert"];
50
+ /**
51
+ * For an editor: the player's header, progress bar and buttons around the step, as a learner has
52
+ * them, so the step gets the room it has in the player. They are drawn but cannot be used.
53
+ */
54
+ courseChrome?: SampleChrome | null;
55
+ }
56
+ /** What the player's chrome shows around a previewed step. */
57
+ export interface SampleChrome {
58
+ /** The course's title, in the header. */
59
+ title: string;
60
+ /** The step's place in the course, from 1. */
61
+ position: number;
62
+ count: number;
63
+ /** The course's languages: the header has the language menu when there are several. */
64
+ languages?: PlayerLanguage[];
65
+ cultureId?: string | null;
66
+ /** The slim chrome of a phone on its side. */
67
+ compact?: boolean;
36
68
  }
37
- /** 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;
69
+ /** One step on its own, for previewing a step while it is edited, with or without the player's chrome. */
70
+ export declare function StepView({ step, resolveAsset, mode, quiz, slideId, stepsShown, category, branding, onRevealNavigation, revealAll, renderInsert, courseChrome, }: StepViewProps): import("react").JSX.Element;
@@ -1,13 +1,19 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Alert } from "@digdir/designsystemet-react";
2
+ import { Alert, Button } from "@digdir/designsystemet-react";
3
+ import clsx from "clsx";
3
4
  import { useLayoutEffect, useState } from "react";
4
5
  import { CategoryHeader } from "../chrome/CategoryHeader";
5
- import { getLocalizedString } from "../i18n";
6
+ import { ProgressBar } from "../chrome/ProgressBar";
7
+ import { getLocalizedString, localize } from "../i18n";
8
+ import { CloseIcon } from "../media/icons";
9
+ import { LanguageMenu } from "../player/LanguageMenu";
10
+ import { PlayerControls, PlayerHeader } from "../player/PlayerBars";
6
11
  import { PdfStepView } from "./PdfStepView";
7
12
  import { QuizStepView } from "./QuizStepView";
8
13
  import { SlideStepView } from "./SlideStepView";
9
14
  import { VideoStepView } from "./VideoStepView";
10
15
  import "./StepView.css";
16
+ import "../player/CoursePlayer.css";
11
17
  /** Picks the view for a step's type. A missing document is shown as not available, and counts as done. */
12
18
  export function StepBody({ step, ...props }) {
13
19
  if (!step)
@@ -36,9 +42,19 @@ function MissingStep({ onDoneChange }) {
36
42
  export function StepFrame({ category, branding, children, }) {
37
43
  return (_jsxs(_Fragment, { children: [category && _jsx(CategoryHeader, { ...category, branding: branding }), _jsx("div", { className: "ob-course-step__body", children: children })] }));
38
44
  }
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, }) {
45
+ /** One step on its own, for previewing a step while it is edited, with or without the player's chrome. */
46
+ export function StepView({ step, resolveAsset, mode = "preview", quiz, slideId = 0, stepsShown, category, branding, onRevealNavigation, revealAll, renderInsert, courseChrome, }) {
41
47
  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 }) }) }));
48
+ let frame = (_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, revealAll: revealAll, renderInsert: renderInsert }) }));
49
+ if (!courseChrome)
50
+ return _jsx("div", { className: "ob-course-step ob-course-step--standalone", children: frame });
51
+ return _jsx(SampleChromeView, { chrome: courseChrome, children: frame });
52
+ }
53
+ /** The player's own bars around a step, inert: a tester sees them but cannot move through the course. */
54
+ function SampleChromeView({ chrome, children }) {
55
+ let { title, position, count, languages = [], cultureId = null, compact = false } = chrome;
56
+ let size = compact ? "sm" : undefined;
57
+ let last = position >= count;
58
+ return (_jsxs("div", { className: clsx("ob-course-player", compact && "is-compact"), "data-mode": "preview", children: [_jsx(PlayerHeader, { title: title, size: size, fullScreenLabel: getLocalizedString("Full screen"), inert: true, end: _jsx(Button, { variant: "tertiary", "data-size": "sm", icon: true, "aria-label": getLocalizedString("Close the course"), title: getLocalizedString("Close the course"), children: _jsx(CloseIcon, {}) }), children: languages.length > 1 && _jsx(LanguageMenu, { languages: languages, cultureId: cultureId, onChange: ignore }) }), _jsx(ProgressBar, { length: count, currentIndex: position - 1 }), _jsx("section", { className: "ob-course-step", "aria-label": localize `Step ${position} of ${count}`, children: children }), _jsx(PlayerControls, { size: size, position: position, count: count, backDisabled: position <= 1, nextLabel: last ? getLocalizedString("Complete") : getLocalizedString("Next"), nextArrow: !last, inert: true })] }));
43
59
  }
44
60
  function ignore() { }