-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathCuttingActionsContextMenu.tsx
More file actions
74 lines (66 loc) · 2.4 KB
/
CuttingActionsContextMenu.tsx
File metadata and controls
74 lines (66 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import React from "react";
import { useTranslation } from "react-i18next";
import { LuChevronLeft, LuChevronRight, LuScissors, LuTrash } from "react-icons/lu";
import TrashRestore from "../img/trash-restore.svg?react";
import { ContextMenuItem, ThemedContextMenu } from "./ContextMenu";
import { rewriteKeys } from "../globalKeys";
import { useAppDispatch, useAppSelector } from "../redux/store";
import { cut, markAsDeletedOrAlive, mergeLeft, mergeRight, selectIsCurrentSegmentAlive } from "../redux/videoSlice";
import { selectKeymap } from "../redux/hotkeySlice";
const CuttingActionsContextMenu: React.FC<{
children: React.ReactNode,
}> = ({
children,
}) => {
const { t } = useTranslation();
// Init redux variables
const dispatch = useAppDispatch();
const keymap = useAppSelector(selectKeymap);
const isCurrentSegmentAlive = useAppSelector(selectIsCurrentSegmentAlive);
const cuttingContextMenuItems: ContextMenuItem[] = [
{
name: t("cuttingActions.cut-button"),
action: () => dispatch(cut()),
icon: LuScissors,
hotKey: keymap.cutting.cut.key,
ariaLabel: t("cuttingActions.cut-tooltip-aria", {
hotkeyName: rewriteKeys(keymap.cutting.cut.key),
}),
},
{
name: isCurrentSegmentAlive ? t("cuttingActions.delete-button") : t("cuttingActions.restore-button"),
action: () => dispatch(markAsDeletedOrAlive()),
icon: isCurrentSegmentAlive ? LuTrash : TrashRestore,
hotKey: keymap.cutting.delete.key,
ariaLabel: t("cuttingActions.delete-restore-tooltip-aria", {
hotkeyName: rewriteKeys(keymap.cutting.delete.key),
}),
},
{
name: t("cuttingActions.mergeLeft-button"),
action: () => dispatch(mergeLeft()),
icon: LuChevronLeft,
hotKey: keymap.cutting.mergeLeft.key,
ariaLabel: t("cuttingActions.mergeLeft-tooltip-aria", {
hotkeyName: rewriteKeys(keymap.cutting.mergeLeft.key),
}),
},
{
name: t("cuttingActions.mergeRight-button"),
action: () => dispatch(mergeRight()),
icon: LuChevronRight,
hotKey: keymap.cutting.mergeRight.key,
ariaLabel: t("cuttingActions.mergeRight-tooltip-aria", {
hotkeyName: rewriteKeys(keymap.cutting.mergeRight.key),
}),
},
];
return (
<ThemedContextMenu
menuItems={cuttingContextMenuItems}
>
{children}
</ThemedContextMenu>
);
};
export default CuttingActionsContextMenu;