@olenbetong/synergi-course 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/chrome/CategoryHeader.css +28 -0
- package/es/completion/CourseCompletion.css +53 -0
- package/es/completion/CourseCompletion.d.ts +32 -0
- package/es/completion/CourseCompletion.js +60 -0
- package/es/document/cues.d.ts +51 -6
- package/es/document/cues.js +117 -14
- package/es/document/effects.d.ts +30 -0
- package/es/document/effects.js +76 -0
- package/es/document/schema.d.ts +2722 -346
- package/es/document/schema.js +172 -5
- package/es/document/validate.d.ts +2 -1
- package/es/document/validate.js +83 -16
- package/es/index.d.ts +8 -3
- package/es/index.js +6 -2
- package/es/media/Media.css +16 -0
- package/es/media/icons.d.ts +1 -0
- package/es/media/icons.js +3 -0
- package/es/player/CoursePlayer.css +76 -0
- package/es/player/CoursePlayer.js +28 -13
- package/es/player/PlayerBars.d.ts +32 -0
- package/es/player/PlayerBars.js +14 -0
- package/es/player/useFullScreen.d.ts +17 -0
- package/es/player/useFullScreen.js +83 -0
- package/es/player/useMediaQuery.d.ts +7 -0
- package/es/player/useMediaQuery.js +16 -0
- package/es/steps/Blocks.d.ts +43 -3
- package/es/steps/Blocks.js +114 -26
- package/es/steps/Markdown.d.ts +7 -1
- package/es/steps/Markdown.js +31 -4
- package/es/steps/QuizStepView.d.ts +2 -1
- package/es/steps/QuizStepView.js +20 -10
- package/es/steps/RevealMotion.d.ts +29 -0
- package/es/steps/RevealMotion.js +55 -0
- package/es/steps/SlideStepView.d.ts +5 -3
- package/es/steps/SlideStepView.js +43 -10
- package/es/steps/StepBodyProps.d.ts +16 -1
- package/es/steps/StepView.css +390 -16
- package/es/steps/StepView.d.ts +36 -4
- package/es/steps/StepView.js +21 -5
- package/es/steps/motion.d.ts +59 -0
- package/es/steps/motion.js +136 -0
- package/es/transitions/Transitions.css +114 -0
- package/es/transitions/plan.d.ts +66 -0
- package/es/transitions/plan.js +185 -0
- package/es/transitions/playStepTransition.d.ts +23 -0
- package/es/transitions/playStepTransition.js +131 -0
- package/es/types.d.ts +16 -3
- package/package.json +4 -4
- package/src/chrome/CategoryHeader.css +28 -0
- package/src/completion/CourseCompletion.css +53 -0
- package/src/completion/CourseCompletion.test.tsx +45 -0
- package/src/completion/CourseCompletion.tsx +98 -0
- package/src/document/box.test.ts +234 -0
- package/src/document/cues.ts +143 -13
- package/src/document/document.test.ts +1 -1
- package/src/document/effects.ts +106 -0
- package/src/document/reveal.test.ts +263 -0
- package/src/document/schema.ts +203 -5
- package/src/document/validate.ts +88 -18
- package/src/index.ts +46 -1
- package/src/media/Media.css +16 -0
- package/src/media/icons.tsx +8 -0
- package/src/player/CoursePlayer.css +76 -0
- package/src/player/CoursePlayer.test.tsx +70 -6
- package/src/player/CoursePlayer.tsx +91 -60
- package/src/player/PlayerBars.tsx +106 -0
- package/src/player/fullScreen.test.tsx +70 -0
- package/src/player/useFullScreen.ts +91 -0
- package/src/player/useMediaQuery.ts +21 -0
- package/src/steps/Blocks.test.ts +34 -0
- package/src/steps/Blocks.tsx +219 -32
- package/src/steps/Box.test.tsx +95 -0
- package/src/steps/Markdown.test.tsx +46 -0
- package/src/steps/Markdown.tsx +42 -4
- package/src/steps/Presence.test.tsx +82 -0
- package/src/steps/QuizStepView.test.tsx +79 -0
- package/src/steps/QuizStepView.tsx +34 -12
- package/src/steps/RevealMotion.ts +66 -0
- package/src/steps/SlideStepView.tsx +74 -12
- package/src/steps/StepBodyProps.ts +16 -1
- package/src/steps/StepView.css +390 -16
- package/src/steps/StepView.test.tsx +157 -0
- package/src/steps/StepView.tsx +108 -19
- package/src/steps/motion.test.ts +98 -0
- package/src/steps/motion.ts +178 -0
- package/src/steps/visibility.test.ts +24 -0
- package/src/transitions/Transitions.css +114 -0
- package/src/transitions/plan.ts +258 -0
- package/src/transitions/playStepTransition.ts +162 -0
- package/src/transitions/transitions.test.ts +274 -0
- package/src/types.ts +16 -3
- package/es/Transitions.css +0 -55
- package/es/Transitions.d.ts +0 -10
- package/es/Transitions.js +0 -24
- package/src/Transitions.css +0 -55
- package/src/Transitions.ts +0 -35
package/es/steps/QuizStepView.js
CHANGED
|
@@ -8,7 +8,8 @@ import { Markdown } from "./Markdown";
|
|
|
8
8
|
import "./QuizStepView.css";
|
|
9
9
|
/**
|
|
10
10
|
* A quiz, one question at a time with feedback after each answer, graded by the server.
|
|
11
|
-
* Done when an attempt has passed.
|
|
11
|
+
* Done when an attempt has passed. With `retryUntilCorrect` a wrong answer only says so and the
|
|
12
|
+
* learner answers the same question again; the next question comes after the right answer.
|
|
12
13
|
*/
|
|
13
14
|
export function QuizStepView({ step, slideId, quiz, mode, resolveAsset, subtitles, onSubtitlesChange, onDoneChange, }) {
|
|
14
15
|
let [phase, setPhase] = useState({ name: "intro" });
|
|
@@ -76,11 +77,23 @@ export function QuizStepView({ step, slideId, quiz, mode, resolveAsset, subtitle
|
|
|
76
77
|
let question = attempt.questions[index];
|
|
77
78
|
let nextIndex = attempt.questions.findIndex((candidate, at) => at > index && !candidate.answered);
|
|
78
79
|
let isLast = nextIndex === -1;
|
|
79
|
-
let
|
|
80
|
+
let retry = attempt.retryUntilCorrect === true;
|
|
81
|
+
// A wrong answer in a retry quiz leaves the question open for another answer.
|
|
82
|
+
let answered = feedback != null && (feedback.correct || !retry);
|
|
83
|
+
let tryAgain = feedback != null && !answered;
|
|
80
84
|
let inputName = `ob-course-quiz-${slideId}-${question.questionId}`;
|
|
81
85
|
let answer = () => run(async () => {
|
|
82
86
|
setFeedback(await quiz.answer(slideId, attempt.attemptId, question.questionId, selected));
|
|
83
87
|
});
|
|
88
|
+
let toggle = (optionId, checked) => {
|
|
89
|
+
// Changing the answer after "try again" clears the old verdict, so it is not read as being about the new choice.
|
|
90
|
+
if (tryAgain)
|
|
91
|
+
setFeedback(null);
|
|
92
|
+
if (!question.multiple)
|
|
93
|
+
setSelected([optionId]);
|
|
94
|
+
else
|
|
95
|
+
setSelected((current) => (checked ? [...current, optionId] : current.filter((id) => id !== optionId)));
|
|
96
|
+
};
|
|
84
97
|
let next = () => {
|
|
85
98
|
if (!isLast) {
|
|
86
99
|
setSelected([]);
|
|
@@ -93,12 +106,6 @@ export function QuizStepView({ step, slideId, quiz, mode, resolveAsset, subtitle
|
|
|
93
106
|
setPhase({ name: "result", attempt, result });
|
|
94
107
|
});
|
|
95
108
|
};
|
|
96
|
-
let toggle = (optionId, checked) => {
|
|
97
|
-
if (!question.multiple)
|
|
98
|
-
setSelected([optionId]);
|
|
99
|
-
else
|
|
100
|
-
setSelected((current) => (checked ? [...current, optionId] : current.filter((id) => id !== optionId)));
|
|
101
|
-
};
|
|
102
109
|
return (_jsxs("div", { className: "ob-course-form-step ob-course-quiz", children: [_jsx(Paragraph, { "data-size": "sm", className: "ob-course-hint", children: localize `Question ${index + 1} of ${attempt.questions.length}` }), _jsxs(Fieldset, { disabled: answered || busy, children: [_jsx(Fieldset.Legend, { children: _jsx(Heading, { level: 2, "data-size": "sm", ref: focusRef, tabIndex: -1, className: "ob-course-quiz__question", children: question.text }) }), question.multiple && (_jsx(Fieldset.Description, { children: getLocalizedString("Choose every answer that is right.") })), question.options.map((option) => {
|
|
103
110
|
let props = {
|
|
104
111
|
label: option.text,
|
|
@@ -108,10 +115,13 @@ export function QuizStepView({ step, slideId, quiz, mode, resolveAsset, subtitle
|
|
|
108
115
|
onChange: (event) => toggle(option.optionId, event.currentTarget.checked),
|
|
109
116
|
};
|
|
110
117
|
return question.multiple ? (_jsx(Checkbox, { ...props }, option.optionId)) : (_jsx(Radio, { ...props }, option.optionId));
|
|
111
|
-
})] }), feedback && (_jsxs(Alert, { "data-color": feedback.correct ? "success" : "danger", className: "ob-course-quiz__feedback", children: [_jsx(Heading, { level: 3, "data-size": "2xs", children: feedback.correct ? getLocalizedString("Correct") : getLocalizedString("Not correct") }), feedback.explanation && _jsx(Markdown, { children: feedback.explanation })] })), error, _jsx("div", { children: answered ? (_jsx(Button, { onClick: next, loading: busy, disabled: busy, children: isLast ? getLocalizedString("See the result") : getLocalizedString("Next question") })) : (_jsx(Button, { onClick: answer, loading: busy, disabled: busy || selected.length === 0, children: getLocalizedString("Answer") })) })] }));
|
|
118
|
+
})] }), tryAgain ? (_jsx(Alert, { "data-color": "danger", className: "ob-course-quiz__feedback", children: _jsx(Heading, { level: 3, "data-size": "2xs", children: getLocalizedString("Not correct. Try again.") }) })) : (feedback && (_jsxs(Alert, { "data-color": feedback.correct ? "success" : "danger", className: "ob-course-quiz__feedback", children: [_jsx(Heading, { level: 3, "data-size": "2xs", children: feedback.correct ? getLocalizedString("Correct") : getLocalizedString("Not correct") }), feedback.explanation && _jsx(Markdown, { children: feedback.explanation })] }))), error, _jsx("div", { children: answered ? (_jsx(Button, { onClick: next, loading: busy, disabled: busy, children: isLast ? getLocalizedString("See the result") : getLocalizedString("Next question") })) : (_jsx(Button, { onClick: answer, loading: busy, disabled: busy || selected.length === 0, children: getLocalizedString("Answer") })) })] }));
|
|
112
119
|
}
|
|
113
120
|
let { result } = phase;
|
|
114
|
-
|
|
121
|
+
let retryResult = result != null && (result.retryUntilCorrect ?? phase.attempt.retryUntilCorrect) === true;
|
|
122
|
+
return (_jsxs("div", { className: "ob-course-form-step ob-course-quiz", children: [step.heading && _jsx(Paragraph, { className: "ob-course-hint", children: step.heading }), _jsx(Heading, { level: 2, "data-size": "md", ref: focusRef, tabIndex: -1, children: passed ? getLocalizedString("You passed the quiz") : getLocalizedString("You did not pass the quiz") }), retryResult ? (_jsx(Paragraph, { children: passed
|
|
123
|
+
? getLocalizedString("You answered every question correctly.")
|
|
124
|
+
: getLocalizedString("Answer every question correctly to pass.") })) : result ? (_jsxs(_Fragment, { children: [_jsx(Paragraph, { className: "ob-course-quiz__score", children: localize `You answered ${result.correctCount} of ${result.questionCount} questions correctly (${Math.round(result.percent)} %).` }), _jsx(Paragraph, { children: result.passPercent == null
|
|
115
125
|
? getLocalizedString("Every answer must be correct to pass.")
|
|
116
126
|
: localize `You need ${result.passPercent} % correct answers to pass.` }), result.missedRequired.length > 0 && (_jsx(Alert, { "data-color": "warning", children: result.missedRequired.length === 1
|
|
117
127
|
? getLocalizedString("One of the questions that must be answered correctly was wrong.")
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Component, type RefObject } from "react";
|
|
2
|
+
import { type PartBox } from "./motion";
|
|
3
|
+
/** Whether the learner asked for less motion. Read once per render; the setting rarely changes. */
|
|
4
|
+
export declare function prefersCalm(): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* A part that goes away stays for the length of its fade first. `leaving` lasts `FADE_MS`, then the
|
|
7
|
+
* part is absent; coming back in the meantime makes it present again at once, so stepping back or
|
|
8
|
+
* scrubbing the narration leaves nothing behind.
|
|
9
|
+
*/
|
|
10
|
+
export declare function usePresence(present: boolean, calm: boolean): "present" | "leaving" | "absent";
|
|
11
|
+
interface RevealMotionProps {
|
|
12
|
+
root: RefObject<HTMLElement | null>;
|
|
13
|
+
/** Names what is shown. A change of it with the same `source` is a reveal. */
|
|
14
|
+
signature: string;
|
|
15
|
+
/** The blocks: a change of them is an edit, or another step, and never glides. */
|
|
16
|
+
source: unknown;
|
|
17
|
+
calm: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Glides the parts a reveal pushed to another place, and lifts the parts that fade out out of the
|
|
21
|
+
* flow. Drawn inside the slide; it renders nothing. A class, since `getSnapshotBeforeUpdate` is
|
|
22
|
+
* where React lets a component read the page as it was just before a change is put in it.
|
|
23
|
+
*/
|
|
24
|
+
export declare class RevealMotion extends Component<RevealMotionProps> {
|
|
25
|
+
getSnapshotBeforeUpdate(previous: RevealMotionProps): Map<string, PartBox> | null;
|
|
26
|
+
componentDidUpdate(_previous: RevealMotionProps, _state: unknown, before: Map<string, PartBox> | null): void;
|
|
27
|
+
render(): null;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Component, useEffect, useState } from "react";
|
|
2
|
+
import { FADE_MS, getGlides, measureParts, pinLeaving, runGlides, unpinReturned } from "./motion";
|
|
3
|
+
/** Whether the learner asked for less motion. Read once per render; the setting rarely changes. */
|
|
4
|
+
export function prefersCalm() {
|
|
5
|
+
return typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A part that goes away stays for the length of its fade first. `leaving` lasts `FADE_MS`, then the
|
|
9
|
+
* part is absent; coming back in the meantime makes it present again at once, so stepping back or
|
|
10
|
+
* scrubbing the narration leaves nothing behind.
|
|
11
|
+
*/
|
|
12
|
+
export function usePresence(present, calm) {
|
|
13
|
+
let [leaving, setLeaving] = useState(false);
|
|
14
|
+
let [wasPresent, setWasPresent] = useState(present);
|
|
15
|
+
if (present !== wasPresent) {
|
|
16
|
+
setWasPresent(present);
|
|
17
|
+
setLeaving(!present && !calm);
|
|
18
|
+
}
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!leaving)
|
|
21
|
+
return;
|
|
22
|
+
let timer = setTimeout(() => setLeaving(false), FADE_MS);
|
|
23
|
+
return () => clearTimeout(timer);
|
|
24
|
+
}, [leaving]);
|
|
25
|
+
if (present)
|
|
26
|
+
return "present";
|
|
27
|
+
return leaving ? "leaving" : "absent";
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Glides the parts a reveal pushed to another place, and lifts the parts that fade out out of the
|
|
31
|
+
* flow. Drawn inside the slide; it renders nothing. A class, since `getSnapshotBeforeUpdate` is
|
|
32
|
+
* where React lets a component read the page as it was just before a change is put in it.
|
|
33
|
+
*/
|
|
34
|
+
export class RevealMotion extends Component {
|
|
35
|
+
getSnapshotBeforeUpdate(previous) {
|
|
36
|
+
let element = this.props.root.current;
|
|
37
|
+
let reveal = previous.source === this.props.source && previous.signature !== this.props.signature;
|
|
38
|
+
return reveal && element ? measureParts(element) : null;
|
|
39
|
+
}
|
|
40
|
+
componentDidUpdate(_previous, _state, before) {
|
|
41
|
+
let element = this.props.root.current;
|
|
42
|
+
if (!element)
|
|
43
|
+
return;
|
|
44
|
+
unpinReturned(element);
|
|
45
|
+
if (!before)
|
|
46
|
+
return;
|
|
47
|
+
pinLeaving(element, before);
|
|
48
|
+
if (this.props.calm)
|
|
49
|
+
return;
|
|
50
|
+
runGlides(element, getGlides(before, measureParts(element)));
|
|
51
|
+
}
|
|
52
|
+
render() {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { SlideStep } from "../document/schema";
|
|
2
2
|
import type { StepBodyProps } from "./StepBodyProps";
|
|
3
3
|
/**
|
|
4
|
-
* Blocks on a page.
|
|
5
|
-
* has played to the end (
|
|
4
|
+
* Blocks on a page. With narration, its cues show and hide the parts and the slide is done when it
|
|
5
|
+
* has played to the end (or at once when it is `required: false`); Next and Back go to the other
|
|
6
|
+
* steps. Without, Next shows the parts that wait for it, and the slide is done when no press would
|
|
7
|
+
* show anything more. The slide reports where Next and Back go with `onRevealNavigation`.
|
|
6
8
|
*/
|
|
7
|
-
export declare function SlideStepView({ step, mode, resolveAsset, stepsShown, subtitles, onSubtitlesChange, onDoneChange, onMediaEnded, }: StepBodyProps & {
|
|
9
|
+
export declare function SlideStepView({ step, mode, resolveAsset, stepsShown, subtitles, onSubtitlesChange, onDoneChange, onMediaEnded, onRevealNavigation, revealAll, renderInsert, }: StepBodyProps & {
|
|
8
10
|
step: SlideStep;
|
|
9
11
|
}): import("react").JSX.Element;
|
|
@@ -1,21 +1,32 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import clsx from "clsx";
|
|
3
|
-
import { useEffect, useLayoutEffect, useMemo, useRef } from "react";
|
|
4
|
-
import { getRevealSteps } from "../document/cues";
|
|
3
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { getRevealNavigation, getRevealState, getRevealSteps, getTimedParts } from "../document/cues";
|
|
5
|
+
import { getActiveEffects, getPartEffects } from "../document/effects";
|
|
5
6
|
import { Subtitles } from "../media/MediaControls";
|
|
6
7
|
import { NarrationPlayer, useNarration } from "../media/Narration";
|
|
7
|
-
import { Blocks } from "./Blocks";
|
|
8
|
+
import { Blocks, getVisibility } from "./Blocks";
|
|
9
|
+
import { prefersCalm, RevealMotion } from "./RevealMotion";
|
|
8
10
|
/**
|
|
9
|
-
* Blocks on a page.
|
|
10
|
-
* has played to the end (
|
|
11
|
+
* Blocks on a page. With narration, its cues show and hide the parts and the slide is done when it
|
|
12
|
+
* has played to the end (or at once when it is `required: false`); Next and Back go to the other
|
|
13
|
+
* steps. Without, Next shows the parts that wait for it, and the slide is done when no press would
|
|
14
|
+
* show anything more. The slide reports where Next and Back go with `onRevealNavigation`.
|
|
11
15
|
*/
|
|
12
|
-
export function SlideStepView({ step, mode, resolveAsset, stepsShown, subtitles, onSubtitlesChange, onDoneChange, onMediaEnded, }) {
|
|
13
|
-
let revealSteps = useMemo(() => getRevealSteps(step.blocks), [step.blocks]);
|
|
16
|
+
export function SlideStepView({ step, mode, resolveAsset, stepsShown, subtitles, onSubtitlesChange, onDoneChange, onMediaEnded, onRevealNavigation, revealAll = false, renderInsert, }) {
|
|
14
17
|
let narration = step.narration;
|
|
18
|
+
// On a narrated slide only the narration shows and hides parts; Next goes to the next step
|
|
19
|
+
let narrated = narration != null;
|
|
20
|
+
let revealSteps = useMemo(() => getRevealSteps(step.blocks, narrated), [step.blocks, narrated]);
|
|
15
21
|
let state = useNarration(narration, mode === "learn", onMediaEnded);
|
|
16
22
|
let clock = state.clock;
|
|
23
|
+
let navigation = useMemo(() => getRevealNavigation(step.blocks, stepsShown, clock.startedCues, narrated), [step.blocks, stepsShown, clock.startedCues, narrated]);
|
|
24
|
+
let { next, previous, presses, pressed } = navigation;
|
|
25
|
+
useLayoutEffect(() => {
|
|
26
|
+
onRevealNavigation?.({ next, previous, presses, pressed });
|
|
27
|
+
}, [next, previous, presses, pressed, onRevealNavigation]);
|
|
17
28
|
let mustListen = narration != null && narration.required !== false;
|
|
18
|
-
let done =
|
|
29
|
+
let done = next === null && (!mustListen || clock.ended);
|
|
19
30
|
useLayoutEffect(() => {
|
|
20
31
|
onDoneChange(done);
|
|
21
32
|
}, [done, onDoneChange]);
|
|
@@ -31,12 +42,34 @@ export function SlideStepView({ step, mode, resolveAsset, stepsShown, subtitles,
|
|
|
31
42
|
let calm = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
32
43
|
part?.scrollIntoView?.({ block: "nearest", behavior: calm ? "auto" : "smooth" });
|
|
33
44
|
}, [stepsShown, revealSteps]);
|
|
45
|
+
let reveal = useMemo(() => getRevealState(step.blocks, stepsShown, clock.startedCues, narrated), [step.blocks, stepsShown, clock.startedCues, narrated]);
|
|
46
|
+
// The effects that were shown before this change pick the timing of the parts they act on
|
|
47
|
+
let active = getActiveEffects(step.blocks, reveal);
|
|
48
|
+
let activeKey = [...active].join("\u0000");
|
|
49
|
+
let [effectsSeen, setEffectsSeen] = useState({ key: activeKey, active, previous: active });
|
|
50
|
+
if (effectsSeen.key !== activeKey)
|
|
51
|
+
setEffectsSeen({ key: activeKey, active, previous: effectsSeen.active });
|
|
52
|
+
// An editor that draws every part shows them where they are laid out, not moved by an effect
|
|
53
|
+
let effects = revealAll ? undefined : getPartEffects(step.blocks, reveal, effectsSeen.previous);
|
|
54
|
+
let calm = prefersCalm();
|
|
55
|
+
let signature = getTimedParts(step.blocks)
|
|
56
|
+
.map((part) => `${part.id}:${getVisibility(part, reveal)}`)
|
|
57
|
+
.join("|");
|
|
34
58
|
let context = {
|
|
35
|
-
reveal
|
|
59
|
+
reveal,
|
|
36
60
|
resolveAsset,
|
|
37
61
|
subtitles,
|
|
38
62
|
onSubtitlesChange,
|
|
63
|
+
effects,
|
|
64
|
+
calm,
|
|
65
|
+
revealAll,
|
|
66
|
+
renderInsert,
|
|
39
67
|
};
|
|
40
68
|
let background = step.background ? resolveAsset(step.background) : undefined;
|
|
41
|
-
|
|
69
|
+
// A banner shows the image as a band of its own instead of behind the whole slide
|
|
70
|
+
let banner = step.layout === "banner" && background ? background : undefined;
|
|
71
|
+
if (banner)
|
|
72
|
+
background = undefined;
|
|
73
|
+
let content = (_jsx("div", { className: "ob-course-slide__content", children: _jsx(Blocks, { blocks: step.blocks, context: context, container: { kind: "slide" } }) }));
|
|
74
|
+
return (_jsxs("div", { ref: rootRef, className: clsx("ob-course-slide", `ob-course-slide--${step.layout ?? "default"}`, step.width && `ob-course-slide--${step.width}`, background && "ob-course-slide--background", background && step.panel === false && "ob-course-slide--bare"), children: [_jsx(RevealMotion, { root: rootRef, signature: signature, source: step.blocks, calm: calm }), background && (_jsx("div", { className: "ob-course-slide__background", style: { backgroundImage: `url("${background}")` } })), banner ? (_jsx("div", { className: "ob-course-banner", children: _jsxs("div", { className: "ob-course-banner__stage", children: [_jsx("img", { className: "ob-course-banner__image", src: banner, alt: "" }), content] }) })) : (content), narration && (_jsx(NarrationPlayer, { className: "ob-course-slide__narration", narration: narration, clock: state.clock, setAudio: state.setAudio, resolveAsset: resolveAsset, subtitles: subtitles, onSubtitlesChange: onSubtitlesChange })), _jsx(Subtitles, { cue: subtitles ? clock.activeCue : undefined })] }));
|
|
42
75
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { RevealNavigation } from "../document/cues";
|
|
3
|
+
import type { InsertPlace } from "./Blocks";
|
|
1
4
|
import type { PlayerMode, QuizAdapter, ResolveAsset } from "../types";
|
|
2
5
|
/** What the player hands every step type. */
|
|
3
6
|
export interface StepBodyProps {
|
|
@@ -5,7 +8,10 @@ export interface StepBodyProps {
|
|
|
5
8
|
mode: PlayerMode;
|
|
6
9
|
resolveAsset: ResolveAsset;
|
|
7
10
|
quiz?: QuizAdapter;
|
|
8
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* How many `reveal: "step"` parts of a slide count as pressed, in document order. A press of
|
|
13
|
+
* Next may move it by more than one, past parts that would show nothing new.
|
|
14
|
+
*/
|
|
9
15
|
stepsShown: number;
|
|
10
16
|
subtitles: boolean;
|
|
11
17
|
onSubtitlesChange(subtitles: boolean): void;
|
|
@@ -13,4 +19,13 @@ export interface StepBodyProps {
|
|
|
13
19
|
onDoneChange(done: boolean): void;
|
|
14
20
|
/** The step's narration or video has played to its end; called again after each replay. */
|
|
15
21
|
onMediaEnded?(): void;
|
|
22
|
+
/** A slide reports where Next and Back go from here, and the presses that show something. */
|
|
23
|
+
onRevealNavigation?(navigation: RevealNavigation): void;
|
|
24
|
+
/**
|
|
25
|
+
* For an editor: every part of a slide is drawn, whatever its timing, so each can be reached,
|
|
26
|
+
* and the effects are left off. A part that would not be shown yet carries `is-unrevealed`.
|
|
27
|
+
*/
|
|
28
|
+
revealAll?: boolean;
|
|
29
|
+
/** For an editor: a node drawn at each place on a slide where a block can be added. */
|
|
30
|
+
renderInsert?(place: InsertPlace): ReactNode;
|
|
16
31
|
}
|