'use client'; import React, { useState, ChangeEvent, useEffect } from 'react'; import { motion } from 'framer-motion'; import { Inter } from 'next/font/google'; import { MdKeyboard } from 'react-icons/md'; import { IoMdSearch } from 'react-icons/io'; const inter = Inter({ subsets: ['latin'], weight: '500' }); interface Shortcut { key: string; description: string; } interface ShortcutModalProps { shortcuts: Shortcut[]; mode?: 'light' | 'dark'; } const ShortcutModal: React.FC = ({ shortcuts, mode= 'dark'}) => { const [searchQuery, setSearchQuery] = useState(''); const [isOpen, setIsOpen] = useState(true); const handleSearchChange = (e: ChangeEvent) => { setSearchQuery(e.target.value); }; const filteredShortcuts = shortcuts.filter(shortcut => shortcut.key.toLowerCase().includes(searchQuery.toLowerCase()) || shortcut.description.toLowerCase().includes(searchQuery.toLowerCase()) ); useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { if (event.key === 'Escape' && isOpen) { closeModal(); } else if (event.key === '/' && !isOpen) { openModal(); } }; document.addEventListener('keydown', handleKeyDown); if (isOpen) { document.body.style.overflow = 'hidden'; } else { document.body.style.overflow = ''; } return () => { document.body.style.overflow = ''; document.removeEventListener('keydown', handleKeyDown); }; }, [isOpen]); const closeModal = () => { setIsOpen(false); }; const openModal = () => { setIsOpen(true); }; if (!isOpen) return null; return (
{/* Background Overlay */}
{/* Modal */}

Keyboard Shortcuts

{/* Searchbar */}
{filteredShortcuts.length > 0 ? ( filteredShortcuts.map((shortcut, index) => (

{shortcut.description}

{shortcut.key.split('+').map((key, idx) => ( {key} ))}
)) ) : (

No shortcuts found

)}
{/* Scrollbar Styles */}
); } export default ShortcutModal;