From 7c1595c769c10e7a071af5ad4cf0eb9bee50ca66 Mon Sep 17 00:00:00 2001 From: Prashant-kumar-8312 Date: Fri, 22 May 2026 11:38:08 +0530 Subject: [PATCH] feat: show-shortcut-option --- src/components/KeyboardShortcutPanel.tsx | 101 +++++++++++++++++++++++ src/components/VideoEditor.tsx | 96 +++++++-------------- src/hooks/useVideoEditor.ts | 39 +++++++++ 3 files changed, 168 insertions(+), 68 deletions(-) create mode 100644 src/components/KeyboardShortcutPanel.tsx diff --git a/src/components/KeyboardShortcutPanel.tsx b/src/components/KeyboardShortcutPanel.tsx new file mode 100644 index 00000000..caf07770 --- /dev/null +++ b/src/components/KeyboardShortcutPanel.tsx @@ -0,0 +1,101 @@ +"use client"; + +import { useEffect } from "react"; +import { X } from "lucide-react"; + +interface ShortcutPanelProps { + open: boolean; + onClose: () => void; +} + +const shortcuts = [ + { keys: ["Cmd/Ctrl", "+", "Enter"], action: "Start export" }, + { keys: ["Space"], action: "Play / pause preview" }, + { keys: ["?"], action: "Toggle this shortcut panel" }, + { keys: ["Escape"], action: "Close overlay / cancel" }, + { keys: ["M"], action: "Toggle audio mute" }, +]; + +function ShortcutRow({ keys, action }: { keys: string[]; action: string }) { + return ( +
  • + {action} +
    + {keys.map((key) => ( + + {key} + + ))} +
    +
  • + ); +} + +export default function KeyboardShortcutPanel({ open, onClose }: ShortcutPanelProps) { + useEffect(() => { + if (!open) return; + const onKey = (e: KeyboardEvent) => { + if (e.key === "Escape") onClose(); + }; + + const previousOverflow = document.body.style.overflow; + + document.body.style.overflow = "hidden"; + document.addEventListener("keydown", onKey); + return () => { + document.removeEventListener("keydown", onKey); + document.body.style.overflow = previousOverflow; + }; + }, [open, onClose]); + + if (!open) return null; + + return ( +
    +
    + +
    + ); +} diff --git a/src/components/VideoEditor.tsx b/src/components/VideoEditor.tsx index 69265646..2ced7847 100644 --- a/src/components/VideoEditor.tsx +++ b/src/components/VideoEditor.tsx @@ -16,11 +16,12 @@ import ExportSettings from "./ExportSettings"; import ExportOverlay from "./ExportOverlay"; import DownloadResult from "./DownloadResult"; import ImageOverlay from "./ImageOverlay" +import KeyboardShortcutPanel from "./KeyboardShortcutPanel"; import { cn } from "@/lib/utils"; import { Layers, Crop, Scissors, RotateCw, Volume2, - SlidersHorizontal, Zap, AlertTriangle, Github, Copy + SlidersHorizontal, Zap, AlertTriangle, Copy, HelpCircle } from "lucide-react"; import OnboardingTour from "./OnboardingTour"; @@ -49,66 +50,6 @@ function Section({ icon, title, children, delay = 0 }: SectionProps) { ); } -/** Inline keyboard hint badge. */ -function Kbd({ children }: { children: React.ReactNode }) { - return ( - - {children} - - ); -} - -/** Collapsible panel that lists all keyboard shortcuts. */ -function KeyboardShortcutsPanel() { - const [open, setOpen] = useState(false); - - const shortcuts: { keys: React.ReactNode[]; label: string }[] = [ - { keys: [M], label: "Toggle audio mute" }, - { keys: [Ctrl, +, ], label: "Export video" }, - ]; - - return ( -
    - - - {open && ( -
      - {shortcuts.map(({ keys, label }) => ( -
    • - {label} - {keys} -
    • - ))} -
    - )} -
    - ); -} - export default function VideoEditor() { const { file, duration, recipe, status, progress, @@ -120,6 +61,7 @@ export default function VideoEditor() { overlayPosition, setOverlayPosition, overlaySize, setOverlaySize, overlayOpacity, setOverlayOpacity, + isShortcutPanelOpen, closeShortcutPanel, toggleShortcutPanel, recommendedPreset, toggleSound, } = useVideoEditor(); @@ -161,6 +103,7 @@ export default function VideoEditor() { return (
    +
    @@ -171,7 +114,7 @@ export default function VideoEditor() {
    -
    +
    -
    - - No login. No ads. 100% private - your video never leaves your device. +
    +
    + + No login. No ads. 100% private - your video never leaves your device. +
    +
    @@ -433,9 +396,6 @@ export default function VideoEditor() {
    - - -