import { useEffect, useMemo, useState } from 'react'; import ChartToolMenu, { type ToolMenuSection } from './ChartToolMenu'; import { IconBrush, IconCrosshair, IconCursor, IconEye, IconFib, IconLock, IconPlus, IconRuler, IconSmile, IconText, IconResetView, IconTrash, IconTrendline, IconZoom, IconZoomOut, } from './ChartIcons'; type ActiveTool = 'cursor' | 'fib-retracement'; type Props = { timeframe: string; activeTool: ActiveTool; hasFib: boolean; onToolChange: (tool: ActiveTool) => void; onZoomIn: () => void; onZoomOut: () => void; onResetView: () => void; onClearFib: () => void; }; export default function ChartSideToolbar({ timeframe, activeTool, hasFib, onToolChange, onZoomIn, onZoomOut, onResetView, onClearFib, }: Props) { const [openMenu, setOpenMenu] = useState<'fib' | null>(null); useEffect(() => { if (!openMenu) return; const onKeyDown = (e: KeyboardEvent) => { if (e.key === 'Escape') setOpenMenu(null); }; window.addEventListener('keydown', onKeyDown); return () => window.removeEventListener('keydown', onKeyDown); }, [openMenu]); const fibMenuSections: ToolMenuSection[] = useMemo( () => [ { id: 'fib', title: 'FIBONACCI', items: [ { id: 'fib-retracement', label: 'Fib Retracement', icon: , shortcut: 'Click 2 points' }, { id: 'fib-tb-ext', label: 'Trend-Based Fib Extension', icon: }, { id: 'fib-channel', label: 'Fib Channel', icon: }, { id: 'fib-time-zone', label: 'Fib Time Zone', icon: }, { id: 'fib-speed-fan', label: 'Fib Speed Resistance Fan', icon: }, { id: 'fib-tb-time', label: 'Trend-Based Fib Time', icon: }, { id: 'fib-circles', label: 'Fib Circles', icon: }, { id: 'fib-spiral', label: 'Fib Spiral', icon: }, { id: 'fib-speed-arcs', label: 'Fib Speed Resistance Arcs', icon: }, { id: 'fib-wedge', label: 'Fib Wedge', icon: }, { id: 'pitchfan', label: 'Pitchfan', icon: }, ], }, { id: 'gann', title: 'GANN', items: [ { id: 'gann-box', label: 'Gann Box', icon: }, { id: 'gann-square-fixed', label: 'Gann Square Fixed', icon: }, { id: 'gann-fan', label: 'Gann Fan', icon: }, ], }, ], [] ); return (
{openMenu === 'fib' ? ( <>
setOpenMenu(null)} /> { if (id === 'fib-retracement') onToolChange('fib-retracement'); setOpenMenu(null); }} /> ) : null}
); }