From 9c84e55e01d1d23e93e96bdc74287d3ea599fb0e Mon Sep 17 00:00:00 2001 From: Junaid Khan Date: Sat, 18 Apr 2026 21:11:27 -0400 Subject: [PATCH] altered shortcuts to kbd tag format --- .../editor/panels/preview/toolbar.tsx | 38 +++- .../panels/timeline/timeline-toolbar.tsx | 168 +++++++++++------- apps/web/src/components/ui/kbd.tsx | 10 ++ 3 files changed, 138 insertions(+), 78 deletions(-) create mode 100644 apps/web/src/components/ui/kbd.tsx diff --git a/apps/web/src/components/editor/panels/preview/toolbar.tsx b/apps/web/src/components/editor/panels/preview/toolbar.tsx index 9ee6c822..b3bc649b 100644 --- a/apps/web/src/components/editor/panels/preview/toolbar.tsx +++ b/apps/web/src/components/editor/panels/preview/toolbar.tsx @@ -26,7 +26,9 @@ import { PREVIEW_ZOOM_PRESETS } from "@/lib/preview/zoom"; import { usePreviewViewport } from "./preview-viewport"; import { GridPopover } from "./guide-popover"; import { usePreviewStore } from "@/stores/preview-store"; - +import { useKeyboardShortcutsHelp } from "@/hooks/use-keyboard-shortcuts-help"; +import { Tooltip, TooltipProvider, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip"; +import { Kbd } from "@/components/ui/kbd"; export function PreviewToolbar({ onToggleFullscreen, }: { @@ -135,14 +137,32 @@ function ZoomSelect() { function PlayPauseButton() { const isPlaying = useEditor((e) => e.playback.getIsPlaying()); - + const { shortcuts } = useKeyboardShortcutsHelp(); + const togglePlay = shortcuts.find( + item => item.action === "toggle-play" + ); return ( - + + + + + + + + {togglePlay?.description} +
+ + {togglePlay?.keys?.join(" / ")} + +
+
+
+
); } diff --git a/apps/web/src/components/editor/panels/timeline/timeline-toolbar.tsx b/apps/web/src/components/editor/panels/timeline/timeline-toolbar.tsx index e3482181..0362c330 100644 --- a/apps/web/src/components/editor/panels/timeline/timeline-toolbar.tsx +++ b/apps/web/src/components/editor/panels/timeline/timeline-toolbar.tsx @@ -50,7 +50,7 @@ import { GraphEditorPopover } from "./graph-editor/popover"; import { PopoverTrigger } from "@/components/ui/popover"; import { useGraphEditorController } from "./graph-editor/use-controller"; import { useKeyboardShortcutsHelp } from "@/hooks/use-keyboard-shortcuts-help"; - +import { Kbd } from "@/components/ui/kbd"; export function TimelineToolbar({ zoomLevel, minZoom, @@ -100,7 +100,8 @@ function ToolbarLeftSection() { const shortcutMap = Object.fromEntries( shortcuts.map(s => [s.action, s]) ); - + console.log(shortcutMap); + const selectedElement = @@ -137,78 +138,107 @@ function ToolbarLeftSection() { }); const ToolTipShortcuts = { - "split": { - icon: , - tooltip: `Split element (${shortcutMap["split"]?.keys[0]})`, - disabled: false, - onClick: ({ event }) => - handleAction({ action: "split", event }), - }, + split: { + icon: , + tooltip: ( +
+ Split element + {shortcutMap["split"]?.keys?.[0]} +
+ ), + disabled: false, + onClick: ({ event }) => + handleAction({ action: "split", event }), + }, - "split-left": { - icon: , - tooltip: `Split left (${shortcutMap["split-left"]?.keys[0]})`, - disabled: false, - onClick: ({ event }) => - handleAction({ action: "split-left", event }), - }, + "split-left": { + icon: , + tooltip: ( +
+ Split left + {shortcutMap["split-left"]?.keys?.[0]} +
+ ), + disabled: false, + onClick: ({ event }) => + handleAction({ action: "split-left", event }), + }, - "split-right": { - icon: , - tooltip: `Split right (${shortcutMap["split-right"]?.keys[0]})`, - disabled: false, - onClick: ({ event }) => - handleAction({ action: "split-right", event }), - }, + "split-right": { + icon: , + tooltip: ( +
+ Split right + {shortcutMap["split-right"]?.keys?.[0]} +
+ ), + disabled: false, + onClick: ({ event }) => + handleAction({ action: "split-right", event }), + }, - "toggle-source-audio": { - icon: ( - - ), - tooltip: sourceAudioLabel, - disabled: !canToggleSelectedSourceAudio, - onClick: ({ event }) => - handleAction({ - action: "toggle-source-audio", - event - }), - }, + "toggle-source-audio": { + icon: ( + + ), + tooltip: sourceAudioLabel, + disabled: !canToggleSelectedSourceAudio, + onClick: ({ event }) => + handleAction({ + action: "toggle-source-audio", + event, + }), + }, - "duplicate-selected": { - icon: , - tooltip: "Duplicate element", - disabled: false, - onClick: ({ event }) => - handleAction({ - action: "duplicate-selected", - event - }), - }, + "duplicate-selected": { + icon: , + tooltip: ( +
+ Duplicate element + + {shortcutMap["duplicate-selected"]?.keys?.[0]} + +
+ ), + disabled: false, + onClick: ({ event }) => + handleAction({ + action: "duplicate-selected", + event, + }), + }, - "freeze-frame": { - icon: , - tooltip: "Freeze frame (coming soon)", - disabled: true, - onClick: ({ event: _event }) => {}, - }, + "freeze-frame": { + icon: , + tooltip: "Freeze frame (coming soon)", + disabled: true, + onClick: () => {}, + }, - "delete-selected": { - icon: , - tooltip: `Delete element (${shortcutMap["delete-selected"]?.keys.join(" / ")})`, - disabled: false, - onClick: ({ event }) => - handleAction({ - action: "delete-selected", - event - }), - }, - }; + "delete-selected": { + icon: , + tooltip: ( +
+ Delete element + + {shortcutMap["delete-selected"]?.keys?.join(" / ")} + +
+ ), + disabled: false, + onClick: ({ event }) => + handleAction({ + action: "delete-selected", + event, + }), + }, +}; const handleAction = ({ action, @@ -374,7 +404,7 @@ function ToolbarButton({ buttonWrapper, }: { icon: React.ReactNode; - tooltip: string; + tooltip: React.ReactNode | string; onClick?: ({ event }: { event: React.MouseEvent }) => void; disabled?: boolean; isActive?: boolean; diff --git a/apps/web/src/components/ui/kbd.tsx b/apps/web/src/components/ui/kbd.tsx new file mode 100644 index 00000000..2f83e804 --- /dev/null +++ b/apps/web/src/components/ui/kbd.tsx @@ -0,0 +1,10 @@ +"use client" +import * as React from "react"; + +export const Kbd = ({ children }: { children: React.ReactNode }) => { + return ( + + {children} + + ); +} \ No newline at end of file