@capytale/meta-player 0.2.4 → 0.3.1
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/package.json +8 -2
- package/src/demo.tsx +4 -0
- package/src/features/activityData/activityDataSlice.ts +1 -1
- package/src/features/navbar/ActivityInfo.tsx +3 -1
- package/src/features/navbar/ActivityQuickActions.tsx +5 -1
- package/src/features/navbar/ActivitySidebarActions.tsx +5 -1
- package/src/features/navbar/navbarSlice.ts +33 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capytale/meta-player",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -13,6 +13,11 @@
|
|
|
13
13
|
"lint:fix": "eslint --fix .",
|
|
14
14
|
"type-check": "tsc --noEmit"
|
|
15
15
|
},
|
|
16
|
+
"overrides": {
|
|
17
|
+
"use-file-upload": {
|
|
18
|
+
"react": "^18.3.1"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
16
21
|
"dependencies": {
|
|
17
22
|
"@capytale/activity.js": "^3.1.0",
|
|
18
23
|
"@capytale/capytale-anti-triche": "^0.2.1",
|
|
@@ -23,7 +28,8 @@
|
|
|
23
28
|
"primereact": "^10.8.3",
|
|
24
29
|
"react-html-props": "^2.0.9",
|
|
25
30
|
"react-redux": "^9.1.0",
|
|
26
|
-
"screenfull": "^6.0.2"
|
|
31
|
+
"screenfull": "^6.0.2",
|
|
32
|
+
"use-file-upload": "^1.0.11"
|
|
27
33
|
},
|
|
28
34
|
"devDependencies": {
|
|
29
35
|
"@testing-library/dom": "^9.3.4",
|
package/src/demo.tsx
CHANGED
|
@@ -15,11 +15,13 @@ const DemoActivity: FC = () => {
|
|
|
15
15
|
<ActivityQuickActionsSetter
|
|
16
16
|
actions={[
|
|
17
17
|
{
|
|
18
|
+
type: "action",
|
|
18
19
|
title: "Pause",
|
|
19
20
|
icon: "pi pi-pause",
|
|
20
21
|
action: () => console.log("Pause"),
|
|
21
22
|
},
|
|
22
23
|
{
|
|
24
|
+
type: "action",
|
|
23
25
|
title: "Play",
|
|
24
26
|
icon: "pi pi-play",
|
|
25
27
|
action: () => console.log("Play"),
|
|
@@ -29,11 +31,13 @@ const DemoActivity: FC = () => {
|
|
|
29
31
|
<ActivitySidebarActionsSetter
|
|
30
32
|
actions={[
|
|
31
33
|
{
|
|
34
|
+
type: "action",
|
|
32
35
|
title: "Pause",
|
|
33
36
|
icon: "pi pi-pause",
|
|
34
37
|
action: () => console.log("Pause"),
|
|
35
38
|
},
|
|
36
39
|
{
|
|
40
|
+
type: "action",
|
|
37
41
|
title: "Play",
|
|
38
42
|
icon: "pi pi-play",
|
|
39
43
|
action: () => console.log("Play"),
|
|
@@ -30,7 +30,9 @@ const ActivityInfo: React.FC = () => {
|
|
|
30
30
|
className={styles.activityLogo}
|
|
31
31
|
src={icon.path}
|
|
32
32
|
style={{
|
|
33
|
-
backgroundColor: icon.style
|
|
33
|
+
backgroundColor: icon.style
|
|
34
|
+
? icon.style["background-color"] || "white"
|
|
35
|
+
: "white",
|
|
34
36
|
}}
|
|
35
37
|
/>
|
|
36
38
|
)}
|
|
@@ -4,12 +4,14 @@ import {
|
|
|
4
4
|
QuickAction,
|
|
5
5
|
selectQuickActions,
|
|
6
6
|
setQuickActions,
|
|
7
|
+
usePerformQuickAction,
|
|
7
8
|
} from "./navbarSlice";
|
|
8
9
|
import { Button } from "primereact/button";
|
|
9
10
|
import settings from "../../settings";
|
|
10
11
|
|
|
11
12
|
const ActivityQuickActions: FC<{}> = () => {
|
|
12
13
|
const quickActions = useAppSelector(selectQuickActions);
|
|
14
|
+
const performQuickAction = usePerformQuickAction();
|
|
13
15
|
return (
|
|
14
16
|
<>
|
|
15
17
|
{quickActions.map((action) => (
|
|
@@ -18,7 +20,9 @@ const ActivityQuickActions: FC<{}> = () => {
|
|
|
18
20
|
severity="secondary"
|
|
19
21
|
size="small"
|
|
20
22
|
icon={action.icon}
|
|
21
|
-
onClick={
|
|
23
|
+
onClick={() => {
|
|
24
|
+
performQuickAction(action);
|
|
25
|
+
}}
|
|
22
26
|
outlined
|
|
23
27
|
tooltip={action.title}
|
|
24
28
|
tooltipOptions={{
|
|
@@ -4,12 +4,14 @@ import {
|
|
|
4
4
|
QuickAction,
|
|
5
5
|
selectSidebarActions,
|
|
6
6
|
setSidebarActions,
|
|
7
|
+
usePerformQuickAction,
|
|
7
8
|
} from "./navbarSlice";
|
|
8
9
|
import { Button } from "primereact/button";
|
|
9
10
|
import settings from "../../settings";
|
|
10
11
|
|
|
11
12
|
const ActivitySidebarActions: FC<{}> = () => {
|
|
12
13
|
const sidebarActions = useAppSelector(selectSidebarActions);
|
|
14
|
+
const performQuickAction = usePerformQuickAction();
|
|
13
15
|
return (
|
|
14
16
|
<>
|
|
15
17
|
{sidebarActions.map((action) => (
|
|
@@ -18,7 +20,9 @@ const ActivitySidebarActions: FC<{}> = () => {
|
|
|
18
20
|
severity="secondary"
|
|
19
21
|
size="small"
|
|
20
22
|
icon={action.icon}
|
|
21
|
-
onClick={
|
|
23
|
+
onClick={() => {
|
|
24
|
+
performQuickAction(action);
|
|
25
|
+
}}
|
|
22
26
|
outlined
|
|
23
27
|
label={action.title}
|
|
24
28
|
tooltipOptions={{
|
|
@@ -1,11 +1,39 @@
|
|
|
1
1
|
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
2
2
|
import { createAppSlice } from "../../app/createAppSlice";
|
|
3
|
+
import { Callback, useFileUpload } from "use-file-upload";
|
|
4
|
+
export type QuickAction =
|
|
5
|
+
| {
|
|
6
|
+
type: "action";
|
|
7
|
+
title: string;
|
|
8
|
+
icon: string;
|
|
9
|
+
action: () => void;
|
|
10
|
+
}
|
|
11
|
+
| {
|
|
12
|
+
type: "file-upload";
|
|
13
|
+
accept?: string;
|
|
14
|
+
title: string;
|
|
15
|
+
icon: string;
|
|
16
|
+
action: (file: {
|
|
17
|
+
source: URL;
|
|
18
|
+
name: string;
|
|
19
|
+
size: number;
|
|
20
|
+
file: File;
|
|
21
|
+
}) => void;
|
|
22
|
+
};
|
|
3
23
|
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
24
|
+
export function usePerformQuickAction() {
|
|
25
|
+
const [_, selectFile] = useFileUpload();
|
|
26
|
+
return (action: QuickAction) => {
|
|
27
|
+
if (action.type === "action") {
|
|
28
|
+
action.action();
|
|
29
|
+
} else if (action.type === "file-upload") {
|
|
30
|
+
selectFile(
|
|
31
|
+
{ accept: action.accept, multiple: false },
|
|
32
|
+
action.action as Callback,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
9
37
|
|
|
10
38
|
export interface NavbarState {
|
|
11
39
|
quickActions: QuickAction[];
|