summaryrefslogtreecommitdiff
path: root/apps/web/src/components/keyboard-shortcuts-help.tsx
diff options
context:
space:
mode:
authorAnwarul Islam <anwaarulislaam@gmail.com>2025-07-18 07:38:32 +0600
committerAnwarul Islam <anwaarulislaam@gmail.com>2025-07-18 07:38:32 +0600
commitcdae10ca0aeaf23d49591cb81fe9dac7b83ff642 (patch)
tree5d57208b23dc2513dddee24bd479e3f9ca662439 /apps/web/src/components/keyboard-shortcuts-help.tsx
parent33531fb3bf2628d5c5c79d43e0e37b543c9384e1 (diff)
downloadopencut-cdae10ca0aeaf23d49591cb81fe9dac7b83ff642.tar.gz
feat: refactor keybinding management and add keybinding editor component
Diffstat (limited to 'apps/web/src/components/keyboard-shortcuts-help.tsx')
-rw-r--r--apps/web/src/components/keyboard-shortcuts-help.tsx36
1 files changed, 34 insertions, 2 deletions
diff --git a/apps/web/src/components/keyboard-shortcuts-help.tsx b/apps/web/src/components/keyboard-shortcuts-help.tsx
index c908b9ce..c40e5eb4 100644
--- a/apps/web/src/components/keyboard-shortcuts-help.tsx
+++ b/apps/web/src/components/keyboard-shortcuts-help.tsx
@@ -11,11 +11,12 @@ import {
DialogTrigger,
} from "./ui/dialog";
import { Badge } from "./ui/badge";
-import { Keyboard } from "lucide-react";
+import { Keyboard, Settings } from "lucide-react";
import {
useKeyboardShortcutsHelp,
KeyboardShortcut,
} from "@/hooks/use-keyboard-shortcuts-help";
+import { KeybindingEditor } from "./keybinding-editor";
const KeyBadge = ({ keyName }: { keyName: string }) => {
// Replace common key names with symbols or friendly names
@@ -88,12 +89,32 @@ const ShortcutItem = ({ shortcut }: { shortcut: KeyboardShortcut }) => {
export const KeyboardShortcutsHelp = () => {
const [open, setOpen] = useState(false);
+ const [showEditor, setShowEditor] = useState(false);
// Get shortcuts from centralized hook
const { shortcuts } = useKeyboardShortcutsHelp();
const categories = Array.from(new Set(shortcuts.map((s) => s.category)));
+ if (showEditor) {
+ return (
+ <Dialog open={open} onOpenChange={setOpen}>
+ <DialogTrigger asChild>
+ <Button variant="text" size="sm" className="gap-2">
+ <Keyboard className="w-4 h-4" />
+ Shortcuts
+ </Button>
+ </DialogTrigger>
+ <DialogContent className="max-w-6xl max-h-[90vh] overflow-y-auto">
+ <KeybindingEditor
+ shortcuts={shortcuts}
+ onClose={() => setShowEditor(false)}
+ />
+ </DialogContent>
+ </Dialog>
+ );
+ }
+
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
@@ -102,7 +123,7 @@ export const KeyboardShortcutsHelp = () => {
Shortcuts
</Button>
</DialogTrigger>
- <DialogContent className="max-w-2xl max-h-[80vh] overflow-y-hidden flex">
+ <DialogContent className="max-w-2xl max-h-[80vh] overflow-y-auto">
<DialogHeader>
<DialogTitle className="flex items-center gap-2">
<Keyboard className="w-5 h-5" />
@@ -114,6 +135,17 @@ export const KeyboardShortcutsHelp = () => {
</DialogDescription>
</DialogHeader>
+ <div className="flex justify-end mb-4">
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => setShowEditor(true)}
+ >
+ <Settings className="w-4 h-4 mr-2" />
+ Customize
+ </Button>
+ </div>
+
<div className="space-y-6">
{categories.map((category) => (
<div key={category} className="flex flex-col gap-1">