@capytale/meta-player 0.8.3 → 0.9.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/.prettierrc.json +4 -4
- package/LICENSE +674 -674
- package/README.md +12 -12
- package/eslint.config.js +28 -28
- package/index.html +15 -15
- package/package.json +60 -60
- package/public/themes/lara-dark-blue/theme.css +7015 -7015
- package/public/themes/lara-light-blue/theme.css +7005 -7005
- package/src/App.tsx +140 -139
- package/src/AppRedux.css +39 -39
- package/src/MetaPlayer.tsx +170 -170
- package/src/activityJs.ts +7 -7
- package/src/app/createAppSlice.ts +6 -6
- package/src/app/hooks.ts +12 -12
- package/src/app/store.ts +52 -52
- package/src/app.module.scss +80 -80
- package/src/demo.tsx +87 -87
- package/src/external/prime.ts +5 -5
- package/src/features/activityData/ExitWarning.ts +28 -28
- package/src/features/activityData/IsAntiCheatExitDetectionDisabledSetter.tsx +19 -19
- package/src/features/activityData/IsDirtySetter.tsx +17 -17
- package/src/features/activityData/MetaPlayerOptionsSetter.tsx +41 -41
- package/src/features/activityData/activityDataSlice.ts +252 -256
- package/src/features/activityData/activityJsData.ts +82 -82
- package/src/features/activityData/hooks.ts +34 -34
- package/src/features/activityData/metaPlayerOptions.ts +23 -23
- package/src/features/activityData/uiState.ts +20 -20
- package/src/features/activityJS/ActivityJSProvider.tsx +339 -339
- package/src/features/activityJS/AfterResetAction.tsx +23 -23
- package/src/features/activityJS/AfterSaveAction.tsx +23 -23
- package/src/features/activityJS/BeforeResetAction.tsx +23 -23
- package/src/features/activityJS/BeforeSaveAction.tsx +23 -23
- package/src/features/activityJS/Saver.tsx +167 -167
- package/src/features/activityJS/hooks.ts +85 -85
- package/src/features/activityJS/internal-hooks.ts +96 -96
- package/src/features/activityJS/saverSlice.ts +96 -96
- package/src/features/activitySettings/ActivitySettingsSetter.tsx +21 -21
- package/src/features/activitySettings/hooks.ts +12 -12
- package/src/features/activitySettings/index.tsx +43 -43
- package/src/features/activitySettings/store.ts +108 -108
- package/src/features/activitySettings/style.module.scss +8 -8
- package/src/features/activitySettings/types.ts +140 -140
- package/src/features/activitySettings/ui.tsx +299 -299
- package/src/features/functionalities/AttachedFilesFunctionality.ts +23 -23
- package/src/features/functionalities/PreviewDialog.tsx +83 -83
- package/src/features/functionalities/functionalitiesSlice.ts +98 -98
- package/src/features/functionalities/hooks.ts +70 -70
- package/src/features/layout/hooks.ts +7 -7
- package/src/features/layout/layoutSlice.ts +93 -90
- package/src/features/navbar/activity-info/index.tsx +54 -54
- package/src/features/navbar/activity-info/style.module.scss +38 -38
- package/src/features/navbar/activity-menu/ActivityQuickActions.tsx +57 -57
- package/src/features/navbar/activity-menu/index.tsx +154 -154
- package/src/features/navbar/activity-menu/style.module.scss +7 -7
- package/src/features/navbar/capytale-menu/CloneDialog.tsx +75 -75
- package/src/features/navbar/capytale-menu/Countdown.tsx +312 -312
- package/src/features/navbar/capytale-menu/CountdownAndSaveButton.tsx +115 -115
- package/src/features/navbar/capytale-menu/index.tsx +260 -260
- package/src/features/navbar/capytale-menu/style.module.scss +8 -8
- package/src/features/navbar/index.tsx +39 -39
- package/src/features/navbar/navbarSlice.ts +79 -79
- package/src/features/navbar/review-navbar/GradingNav.tsx +128 -128
- package/src/features/navbar/review-navbar/index.tsx +18 -18
- package/src/features/navbar/review-navbar/style.module.scss +22 -22
- package/src/features/navbar/sidebars/ActivitySidebarActions.tsx +57 -57
- package/src/features/navbar/sidebars/AttachedFilesSidebarContent.module.scss +43 -43
- package/src/features/navbar/sidebars/AttachedFilesSidebarContent.tsx +181 -181
- package/src/features/navbar/sidebars/SettingsSidebarContent.tsx +192 -192
- package/src/features/navbar/sidebars/style.module.scss +15 -15
- package/src/features/navbar/student-utils.ts +11 -11
- package/src/features/navbar/style.module.scss +65 -65
- package/src/features/pedago/InstructionsEditor.tsx +102 -102
- package/src/features/pedago/PdfEditor.tsx +91 -91
- package/src/features/pedago/PedagoCommands.tsx +353 -353
- package/src/features/pedago/SharedNotesEditor.tsx +144 -144
- package/src/features/pedago/hooks.ts +99 -0
- package/src/features/pedago/index.tsx +197 -207
- package/src/features/pedago/style.module.scss +233 -233
- package/src/features/theming/ThemeSwitcher.tsx +51 -51
- package/src/features/theming/hooks.ts +6 -6
- package/src/features/theming/themingSlice.ts +93 -93
- package/src/features/toast.tsx +38 -38
- package/src/hooks/index.ts +16 -16
- package/src/index.css +132 -132
- package/src/index.ts +90 -90
- package/src/logo.svg +1 -1
- package/src/my_json_data.js +4146 -4146
- package/src/settings.ts +6 -6
- package/src/types.ts +9 -9
- package/src/utils/ButtonDoubleIcon.tsx +35 -35
- package/src/utils/CardSelector.tsx +41 -41
- package/src/utils/ErrorBoundary.tsx +41 -41
- package/src/utils/PopupButton.tsx +134 -134
- package/src/utils/activity.ts +8 -8
- package/src/utils/breakpoints.ts +4 -4
- package/src/utils/capytale.ts +10 -10
- package/src/utils/clipboard.ts +11 -11
- package/src/utils/download.ts +7 -7
- package/src/utils/equality.ts +32 -32
- package/src/utils/server-clock.ts +42 -42
- package/src/utils/style.module.scss +45 -45
- package/src/utils/useFullscreen.ts +65 -65
- package/src/vite-env.d.ts +1 -1
- package/tsconfig.json +28 -28
- package/tsconfig.node.json +9 -9
- package/vite.config.ts +11 -11
package/src/demo.tsx
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import React, { FC } from "react";
|
|
2
|
-
import { createRoot } from "react-dom/client";
|
|
3
|
-
|
|
4
|
-
import { MetaPlayer } from ".";
|
|
5
|
-
import { ActivityQuickActionsSetter } from "./features/navbar/activity-menu/ActivityQuickActions";
|
|
6
|
-
import { ActivitySidebarActionsSetter } from "./features/navbar/sidebars/ActivitySidebarActions";
|
|
7
|
-
// import { useActivityJS } from "./features/activityJS/ActivityJSProvider";
|
|
8
|
-
import BeforeSaveAction from "./features/activityJS/BeforeSaveAction";
|
|
9
|
-
import MetaPlayerOptionsSetter from "./features/activityData/MetaPlayerOptionsSetter";
|
|
10
|
-
|
|
11
|
-
const DemoActivity: FC = () => {
|
|
12
|
-
// const activityJs = useActivityJS();
|
|
13
|
-
return (
|
|
14
|
-
<>
|
|
15
|
-
<ActivityQuickActionsSetter
|
|
16
|
-
actions={[
|
|
17
|
-
{
|
|
18
|
-
type: "action",
|
|
19
|
-
title: "Pause",
|
|
20
|
-
icon: "pi pi-pause",
|
|
21
|
-
action: () => console.log("Pause"),
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
type: "action",
|
|
25
|
-
title: "Play",
|
|
26
|
-
icon: "pi pi-play",
|
|
27
|
-
action: () => console.log("Play"),
|
|
28
|
-
},
|
|
29
|
-
]}
|
|
30
|
-
/>
|
|
31
|
-
<ActivitySidebarActionsSetter
|
|
32
|
-
actions={[
|
|
33
|
-
{
|
|
34
|
-
type: "action",
|
|
35
|
-
title: "Pause",
|
|
36
|
-
icon: "pi pi-pause",
|
|
37
|
-
action: () => console.log("Pause"),
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
type: "action",
|
|
41
|
-
title: "Play",
|
|
42
|
-
icon: "pi pi-play",
|
|
43
|
-
action: () => console.log("Play"),
|
|
44
|
-
},
|
|
45
|
-
]}
|
|
46
|
-
/>
|
|
47
|
-
<BeforeSaveAction
|
|
48
|
-
name="demo"
|
|
49
|
-
callback={() => console.log("Before save")}
|
|
50
|
-
/>
|
|
51
|
-
<BeforeSaveAction
|
|
52
|
-
name="demo2"
|
|
53
|
-
callback={() => {
|
|
54
|
-
console.log("Before save 2");
|
|
55
|
-
// throw new Error("Error in before save 2");
|
|
56
|
-
}}
|
|
57
|
-
/>
|
|
58
|
-
Activité
|
|
59
|
-
</>
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const container = document.getElementById("root");
|
|
64
|
-
|
|
65
|
-
if (container) {
|
|
66
|
-
const root = createRoot(container);
|
|
67
|
-
|
|
68
|
-
root.render(
|
|
69
|
-
<React.StrictMode>
|
|
70
|
-
<MetaPlayer>
|
|
71
|
-
<MetaPlayerOptionsSetter
|
|
72
|
-
options={{
|
|
73
|
-
|
|
74
|
-
pedagoLayout: "default-horizontal",
|
|
75
|
-
supportsLightTheme: true,
|
|
76
|
-
supportsDarkTheme: true,
|
|
77
|
-
}}
|
|
78
|
-
/>
|
|
79
|
-
<DemoActivity />
|
|
80
|
-
</MetaPlayer>
|
|
81
|
-
</React.StrictMode>,
|
|
82
|
-
);
|
|
83
|
-
} else {
|
|
84
|
-
throw new Error(
|
|
85
|
-
"Root element with ID 'root' was not found in the document. Ensure there is a corresponding HTML element with the ID 'root' in your HTML file.",
|
|
86
|
-
);
|
|
87
|
-
}
|
|
1
|
+
import React, { FC } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
|
|
4
|
+
import { MetaPlayer } from ".";
|
|
5
|
+
import { ActivityQuickActionsSetter } from "./features/navbar/activity-menu/ActivityQuickActions";
|
|
6
|
+
import { ActivitySidebarActionsSetter } from "./features/navbar/sidebars/ActivitySidebarActions";
|
|
7
|
+
// import { useActivityJS } from "./features/activityJS/ActivityJSProvider";
|
|
8
|
+
import BeforeSaveAction from "./features/activityJS/BeforeSaveAction";
|
|
9
|
+
import MetaPlayerOptionsSetter from "./features/activityData/MetaPlayerOptionsSetter";
|
|
10
|
+
|
|
11
|
+
const DemoActivity: FC = () => {
|
|
12
|
+
// const activityJs = useActivityJS();
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
<ActivityQuickActionsSetter
|
|
16
|
+
actions={[
|
|
17
|
+
{
|
|
18
|
+
type: "action",
|
|
19
|
+
title: "Pause",
|
|
20
|
+
icon: "pi pi-pause",
|
|
21
|
+
action: () => console.log("Pause"),
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: "action",
|
|
25
|
+
title: "Play",
|
|
26
|
+
icon: "pi pi-play",
|
|
27
|
+
action: () => console.log("Play"),
|
|
28
|
+
},
|
|
29
|
+
]}
|
|
30
|
+
/>
|
|
31
|
+
<ActivitySidebarActionsSetter
|
|
32
|
+
actions={[
|
|
33
|
+
{
|
|
34
|
+
type: "action",
|
|
35
|
+
title: "Pause",
|
|
36
|
+
icon: "pi pi-pause",
|
|
37
|
+
action: () => console.log("Pause"),
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
type: "action",
|
|
41
|
+
title: "Play",
|
|
42
|
+
icon: "pi pi-play",
|
|
43
|
+
action: () => console.log("Play"),
|
|
44
|
+
},
|
|
45
|
+
]}
|
|
46
|
+
/>
|
|
47
|
+
<BeforeSaveAction
|
|
48
|
+
name="demo"
|
|
49
|
+
callback={() => console.log("Before save")}
|
|
50
|
+
/>
|
|
51
|
+
<BeforeSaveAction
|
|
52
|
+
name="demo2"
|
|
53
|
+
callback={() => {
|
|
54
|
+
console.log("Before save 2");
|
|
55
|
+
// throw new Error("Error in before save 2");
|
|
56
|
+
}}
|
|
57
|
+
/>
|
|
58
|
+
Activité
|
|
59
|
+
</>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const container = document.getElementById("root");
|
|
64
|
+
|
|
65
|
+
if (container) {
|
|
66
|
+
const root = createRoot(container);
|
|
67
|
+
|
|
68
|
+
root.render(
|
|
69
|
+
<React.StrictMode>
|
|
70
|
+
<MetaPlayer>
|
|
71
|
+
<MetaPlayerOptionsSetter
|
|
72
|
+
options={{
|
|
73
|
+
showPedagoByDefault: true,
|
|
74
|
+
pedagoLayout: "default-horizontal",
|
|
75
|
+
supportsLightTheme: true,
|
|
76
|
+
supportsDarkTheme: true,
|
|
77
|
+
}}
|
|
78
|
+
/>
|
|
79
|
+
<DemoActivity />
|
|
80
|
+
</MetaPlayer>
|
|
81
|
+
</React.StrictMode>,
|
|
82
|
+
);
|
|
83
|
+
} else {
|
|
84
|
+
throw new Error(
|
|
85
|
+
"Root element with ID 'root' was not found in the document. Ensure there is a corresponding HTML element with the ID 'root' in your HTML file.",
|
|
86
|
+
);
|
|
87
|
+
}
|
package/src/external/prime.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Toast } from "primereact/toast";
|
|
2
|
-
import type { ToastMessage } from "primereact/toast";
|
|
3
|
-
|
|
4
|
-
export { Toast };
|
|
5
|
-
export type { ToastMessage };
|
|
1
|
+
import { Toast } from "primereact/toast";
|
|
2
|
+
import type { ToastMessage } from "primereact/toast";
|
|
3
|
+
|
|
4
|
+
export { Toast };
|
|
5
|
+
export type { ToastMessage };
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { FC, useEffect } from "react";
|
|
2
|
-
import { useCanSave } from "./hooks";
|
|
3
|
-
import { useAppSelector } from "../../app/hooks";
|
|
4
|
-
import { selectIsDirty } from "./activityDataSlice";
|
|
5
|
-
|
|
6
|
-
const ExitWarning: FC = () => {
|
|
7
|
-
const canSave = useCanSave();
|
|
8
|
-
const isDirty = useAppSelector(selectIsDirty);
|
|
9
|
-
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
const handleBeforeUnload = (e: BeforeUnloadEvent) => {
|
|
12
|
-
if (canSave && isDirty) {
|
|
13
|
-
e.preventDefault();
|
|
14
|
-
e.returnValue = true;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
19
|
-
|
|
20
|
-
return () => {
|
|
21
|
-
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
22
|
-
};
|
|
23
|
-
}, [canSave, isDirty]);
|
|
24
|
-
|
|
25
|
-
return null;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default ExitWarning;
|
|
1
|
+
import { FC, useEffect } from "react";
|
|
2
|
+
import { useCanSave } from "./hooks";
|
|
3
|
+
import { useAppSelector } from "../../app/hooks";
|
|
4
|
+
import { selectIsDirty } from "./activityDataSlice";
|
|
5
|
+
|
|
6
|
+
const ExitWarning: FC = () => {
|
|
7
|
+
const canSave = useCanSave();
|
|
8
|
+
const isDirty = useAppSelector(selectIsDirty);
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const handleBeforeUnload = (e: BeforeUnloadEvent) => {
|
|
12
|
+
if (canSave && isDirty) {
|
|
13
|
+
e.preventDefault();
|
|
14
|
+
e.returnValue = true;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
19
|
+
|
|
20
|
+
return () => {
|
|
21
|
+
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
22
|
+
};
|
|
23
|
+
}, [canSave, isDirty]);
|
|
24
|
+
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default ExitWarning;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { FC, useEffect } from "react";
|
|
2
|
-
import { setIsAntiCheatExitDetectionDisabled } from "./activityDataSlice";
|
|
3
|
-
import { useAppDispatch } from "../../app/hooks";
|
|
4
|
-
|
|
5
|
-
type IsAntiCheatExitDetectionDisabledSetterProps = {
|
|
6
|
-
isDisabled: boolean;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const IsAntiCheatExitDetectionDisabledSetter: FC<
|
|
10
|
-
IsAntiCheatExitDetectionDisabledSetterProps
|
|
11
|
-
> = (props) => {
|
|
12
|
-
const dispatch = useAppDispatch();
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
dispatch(setIsAntiCheatExitDetectionDisabled(props.isDisabled));
|
|
15
|
-
}, [props]);
|
|
16
|
-
return null;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default IsAntiCheatExitDetectionDisabledSetter;
|
|
1
|
+
import { FC, useEffect } from "react";
|
|
2
|
+
import { setIsAntiCheatExitDetectionDisabled } from "./activityDataSlice";
|
|
3
|
+
import { useAppDispatch } from "../../app/hooks";
|
|
4
|
+
|
|
5
|
+
type IsAntiCheatExitDetectionDisabledSetterProps = {
|
|
6
|
+
isDisabled: boolean;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const IsAntiCheatExitDetectionDisabledSetter: FC<
|
|
10
|
+
IsAntiCheatExitDetectionDisabledSetterProps
|
|
11
|
+
> = (props) => {
|
|
12
|
+
const dispatch = useAppDispatch();
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
dispatch(setIsAntiCheatExitDetectionDisabled(props.isDisabled));
|
|
15
|
+
}, [props]);
|
|
16
|
+
return null;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default IsAntiCheatExitDetectionDisabledSetter;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { FC, useEffect } from "react";
|
|
2
|
-
import { setIsPlayerDirty } from "./activityDataSlice";
|
|
3
|
-
import { useAppDispatch } from "../../app/hooks";
|
|
4
|
-
|
|
5
|
-
type IsDirtySetterProps = {
|
|
6
|
-
isDirty: boolean;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const IsDirtySetter: FC<IsDirtySetterProps> = (props) => {
|
|
10
|
-
const dispatch = useAppDispatch();
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
dispatch(setIsPlayerDirty(props.isDirty));
|
|
13
|
-
}, [props]);
|
|
14
|
-
return null;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default IsDirtySetter;
|
|
1
|
+
import { FC, useEffect } from "react";
|
|
2
|
+
import { setIsPlayerDirty } from "./activityDataSlice";
|
|
3
|
+
import { useAppDispatch } from "../../app/hooks";
|
|
4
|
+
|
|
5
|
+
type IsDirtySetterProps = {
|
|
6
|
+
isDirty: boolean;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const IsDirtySetter: FC<IsDirtySetterProps> = (props) => {
|
|
10
|
+
const dispatch = useAppDispatch();
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
dispatch(setIsPlayerDirty(props.isDirty));
|
|
13
|
+
}, [props]);
|
|
14
|
+
return null;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default IsDirtySetter;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { FC, useEffect } from "react";
|
|
2
|
-
import { useAppDispatch } from "../../app/hooks";
|
|
3
|
-
import { setPlayerSettings } from "./activityDataSlice";
|
|
4
|
-
import { setLayout } from "../layout/layoutSlice";
|
|
5
|
-
import { setAutoSwitch, switchToTheme } from "../theming/themingSlice";
|
|
6
|
-
import {
|
|
7
|
-
defaultMetaPlayerOptions,
|
|
8
|
-
MetaPlayerOptions,
|
|
9
|
-
} from "./metaPlayerOptions";
|
|
10
|
-
|
|
11
|
-
type MetaPlayerOptionsSetterProps = {
|
|
12
|
-
options: Partial<MetaPlayerOptions>;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const MetaPlayerOptionsSetter: FC<MetaPlayerOptionsSetterProps> = (props) => {
|
|
16
|
-
const dispatch = useAppDispatch();
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
const options = { ...defaultMetaPlayerOptions, ...props.options };
|
|
19
|
-
if (!options.supportsLightTheme && !options.supportsDarkTheme) {
|
|
20
|
-
throw new Error("At least one theme must be supported");
|
|
21
|
-
}
|
|
22
|
-
dispatch(setPlayerSettings(options));
|
|
23
|
-
dispatch(
|
|
24
|
-
setLayout(
|
|
25
|
-
options.pedagoLayout === "horizontal" ||
|
|
26
|
-
options.pedagoLayout === "default-horizontal"
|
|
27
|
-
? "horizontal"
|
|
28
|
-
: "vertical",
|
|
29
|
-
),
|
|
30
|
-
);
|
|
31
|
-
if (options.supportsDarkTheme && options.supportsLightTheme) {
|
|
32
|
-
dispatch(setAutoSwitch(true));
|
|
33
|
-
} else {
|
|
34
|
-
dispatch(setAutoSwitch(false));
|
|
35
|
-
dispatch(switchToTheme(options.supportsLightTheme ? "light" : "dark"));
|
|
36
|
-
}
|
|
37
|
-
}, [dispatch, props.options]);
|
|
38
|
-
return null;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export default MetaPlayerOptionsSetter;
|
|
1
|
+
import { FC, useEffect } from "react";
|
|
2
|
+
import { useAppDispatch } from "../../app/hooks";
|
|
3
|
+
import { setPlayerSettings } from "./activityDataSlice";
|
|
4
|
+
import { setLayout } from "../layout/layoutSlice";
|
|
5
|
+
import { setAutoSwitch, switchToTheme } from "../theming/themingSlice";
|
|
6
|
+
import {
|
|
7
|
+
defaultMetaPlayerOptions,
|
|
8
|
+
MetaPlayerOptions,
|
|
9
|
+
} from "./metaPlayerOptions";
|
|
10
|
+
|
|
11
|
+
type MetaPlayerOptionsSetterProps = {
|
|
12
|
+
options: Partial<MetaPlayerOptions>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const MetaPlayerOptionsSetter: FC<MetaPlayerOptionsSetterProps> = (props) => {
|
|
16
|
+
const dispatch = useAppDispatch();
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const options = { ...defaultMetaPlayerOptions, ...props.options };
|
|
19
|
+
if (!options.supportsLightTheme && !options.supportsDarkTheme) {
|
|
20
|
+
throw new Error("At least one theme must be supported");
|
|
21
|
+
}
|
|
22
|
+
dispatch(setPlayerSettings(options));
|
|
23
|
+
dispatch(
|
|
24
|
+
setLayout(
|
|
25
|
+
options.pedagoLayout === "horizontal" ||
|
|
26
|
+
options.pedagoLayout === "default-horizontal"
|
|
27
|
+
? "horizontal"
|
|
28
|
+
: "vertical",
|
|
29
|
+
),
|
|
30
|
+
);
|
|
31
|
+
if (options.supportsDarkTheme && options.supportsLightTheme) {
|
|
32
|
+
dispatch(setAutoSwitch(true));
|
|
33
|
+
} else {
|
|
34
|
+
dispatch(setAutoSwitch(false));
|
|
35
|
+
dispatch(switchToTheme(options.supportsLightTheme ? "light" : "dark"));
|
|
36
|
+
}
|
|
37
|
+
}, [dispatch, props.options]);
|
|
38
|
+
return null;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default MetaPlayerOptionsSetter;
|