import { useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { X } from 'lucide-react'; interface ShortcutGroup { title: string; shortcuts: { keys: string[]; description: string }[]; } const shortcutGroups: ShortcutGroup[] = [ { title: 'General', shortcuts: [ { keys: ['Ctrl', 'K'], description: 'Open search' }, { keys: ['?'], description: 'Show keyboard shortcuts' }, { keys: ['Esc'], description: 'Close dialog / panel' }, ], }, { title: 'Playback', shortcuts: [ { keys: ['Space'], description: 'Play / Pause' }, { keys: ['N'], description: 'Next track' }, { keys: ['P'], description: 'Previous track' }, { keys: ['M'], description: 'Toggle mute' }, { keys: ['↑'], description: 'Volume up' }, { keys: ['↓'], description: 'Volume down' }, ], }, { title: 'Navigation', shortcuts: [ { keys: ['G', 'H'], description: 'Go to Home' }, { keys: ['G', 'L'], description: 'Go to Library' }, { keys: ['G', 'S'], description: 'Go to Settings' }, ], }, ]; interface KeyboardShortcutsPanelProps { isOpen: boolean; onClose: () => void; } export function KeyboardShortcutsPanel({ isOpen, onClose, }: KeyboardShortcutsPanelProps) { useEffect(() => { if (!isOpen) return; const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'Escape' || e.key === '?') { e.preventDefault(); onClose(); } }; window.addEventListener('keydown', handleKeyDown); return () => window.removeEventListener('keydown', handleKeyDown); }, [isOpen, onClose]); return ( {isOpen && ( <> {/* Backdrop */} {/* Panel */} {/* Header */}

Keyboard Shortcuts

{/* Groups */}
{shortcutGroups.map((group) => (

{group.title}

{group.shortcuts.map((shortcut) => (
{shortcut.description}
{shortcut.keys.map((key, i) => ( {key} {i < shortcut.keys.length - 1 && ( + )} ))}
))}
))}
{/* Footer */}

Press{' '} ? {' '} to toggle this panel

)}
); }