Elffuss BraidHub

kikocis/osiris public

master · 2.9 KiBRawPermalink
1'use client';
2
3import { useState, useEffect } from 'react';
4import { motion, AnimatePresence } from 'framer-motion';
5import { Keyboard, X } from 'lucide-react';
6
7const SHORTCUTS = [
8 { key: 'F', desc: 'Toggle fullscreen' },
9 { key: 'S', desc: 'Share current view' },
10 { key: 'L', desc: 'Toggle layer panel' },
11 { key: 'M', desc: 'Toggle markets panel' },
12 { key: 'I', desc: 'Toggle intel feed' },
13 { key: 'R', desc: 'Reset to global view' },
14 { key: '?', desc: 'Show this help' },
15 { key: 'ESC', desc: 'Close panels / popups' },
16];
17
18export default function KeyboardShortcuts() {
19 const [isOpen, setIsOpen] = useState(false);
20
21 useEffect(() => {
22 const handler = (e: KeyboardEvent) => {
23 if (['INPUT', 'TEXTAREA'].includes((e.target as Element)?.tagName)) return;
24 if (e.key === '?' || (e.key === '/' && e.shiftKey)) setIsOpen(p => !p);
25 if (e.key === 'Escape') setIsOpen(false);
26 };
27 window.addEventListener('keydown', handler);
28 return () => window.removeEventListener('keydown', handler);
29 }, []);
30
31 return (
32 <AnimatePresence>
33 {isOpen && (
34 <motion.div
35 initial={{ opacity: 0, scale: 0.95 }}
36 animate={{ opacity: 1, scale: 1 }}
37 exit={{ opacity: 0, scale: 0.95 }}
38 className="fixed inset-0 z-[500] flex items-center justify-center pointer-events-auto"
39 onClick={() => setIsOpen(false)}
40 >
41 <div className="absolute inset-0 bg-[var(--bg-void)]/80 backdrop-blur-sm" />
42 <motion.div
43 onClick={e => e.stopPropagation()}
44 className="relative glass-panel p-6 w-[320px] osiris-glow"
45 >
46 <div className="flex items-center justify-between mb-4">
47 <div className="flex items-center gap-2">
48 <Keyboard className="w-4 h-4 text-[var(--gold-primary)]" />
49 <span className="text-sm font-mono font-bold text-[var(--text-heading)] tracking-wider">SHORTCUTS</span>
50 </div>
51 <button onClick={() => setIsOpen(false)} className="text-[var(--text-muted)] hover:text-[var(--text-primary)]">
52 <X className="w-4 h-4" />
53 </button>
54 </div>
55 <div className="space-y-2">
56 {SHORTCUTS.map(s => (
57 <div key={s.key} className="flex items-center justify-between">
58 <span className="text-[9px] font-mono text-[var(--text-secondary)]">{s.desc}</span>
59 <kbd className="px-2 py-0.5 rounded text-[8px] font-mono font-bold text-[var(--gold-primary)] bg-[var(--bg-void)] border border-[var(--border-primary)]">
60 {s.key}
61 </kbd>
62 </div>
63 ))}
64 </div>
65 <div className="mt-4 text-center text-[7px] font-mono text-[var(--text-muted)] tracking-widest">
66 PRESS [?] OR [ESC] TO CLOSE
67 </div>
68 </motion.div>
69 </motion.div>
70 )}
71 </AnimatePresence>
72 );
73}