import React, { useEffect, useState } from "react"; import { X } from "@phosphor-icons/react"; import { useTranslation } from "react-i18next"; import { SHORTCUTS, isMac, KEYBOARD_SHORTCUTS_HELP_EVENT, } from "@/utils/keyboardShortcuts"; export default function KeyboardShortcutsHelp() { const [isOpen, setIsOpen] = useState(false); const { t } = useTranslation(); useEffect(() => { window.addEventListener(KEYBOARD_SHORTCUTS_HELP_EVENT, () => setIsOpen((prev) => !prev) ); return () => { window.removeEventListener(KEYBOARD_SHORTCUTS_HELP_EVENT, () => setIsOpen(false) ); }; }, []); if (!isOpen) return null; return (

{t("keyboard-shortcuts.title")}

{Object.entries(SHORTCUTS).map(([key, shortcut]) => (
{t(`keyboard-shortcuts.shortcuts.${shortcut.translationKey}`)} {isMac ? key : key.replace("⌘", "Ctrl")}
))}
); }