import { useRef, useState } from 'react'; import { Link, useLocation } from 'react-router'; import type { LucideIcon } from 'lucide-react'; export type DockItem = { label: string; to: string; icon: LucideIcon; color: string; }; type DockProps = { items: DockItem[]; className?: string; }; const ICON_SIZE = 48; const ICON_GAP = 24; const DOCK_PADDING = 12; const MAX_SCALE = 1.5; const MAX_DISTANCE = 150; const getScale = (mouseX: number | null, iconCenterX: number) => { if (mouseX === null) return 1; const distance = Math.abs(mouseX - iconCenterX); if (distance > MAX_DISTANCE) return 1; return 1 + (MAX_SCALE - 1) * Math.cos((distance / MAX_DISTANCE) * (Math.PI / 2)); }; export const Dock = ({ items, className }: DockProps) => { const [mouseX, setMouseX] = useState(null); const dockRef = useRef(null); const location = useLocation(); const isActive = (to: string) => location.pathname.startsWith(to); const handleMouseMove = (ev: React.MouseEvent) => { const rect = dockRef.current?.getBoundingClientRect(); if (rect) setMouseX(ev.clientX - rect.left); }; const handleMouseLeave = () => setMouseX(null); return (
{items.map((item, index) => { const iconCenter = DOCK_PADDING + index * (ICON_SIZE + ICON_GAP) + ICON_SIZE / 2; const scale = getScale(mouseX, iconCenter); const active = isActive(item.to); return ( {item.label}
{active && (
)} ); })}
); }; import { MessageCircle, TerminalSquare, FileText, FolderOpen, Code, LayoutGrid, Bot, ScrollText } from 'lucide-react'; export const dockItems: DockItem[] = [ { label: 'Files', to: '/files', icon: FolderOpen, color: '#fbbf24' }, { label: 'Chat', to: '/chat', icon: MessageCircle, color: '#60a5fa' }, { label: 'Terminal', to: '/terminal', icon: TerminalSquare, color: '#34d399' }, { label: 'Editor', to: '/code-editor', icon: Code, color: '#a78bfa' }, { label: 'Plans', to: '/plans', icon: FileText, color: '#f472b6' }, { label: 'Automation', to: '/automation', icon: Bot, color: '#2dd4bf' }, { label: 'Logs', to: '/task-logs', icon: ScrollText, color: '#94a3b8' }, { label: 'Workspaces', to: '/workspaces', icon: LayoutGrid, color: '#8b5cf6' }, ];