import { Maximize, Minus, Plus, Redo2, Undo2 } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { Panel, useReactFlow, useStore } from 'reactflow'; import { IconButton } from '@/components/ui/icon-button'; import { Separator } from '@/components/ui/separator'; interface CanvasControlsProps { onUndo: () => void; onRedo: () => void; canUndo: boolean; canRedo: boolean; } const ZOOM_DURATION_MS = 200; /** * The canvas's one control strip, bottom left: undo and redo, then zoom out, * the zoom level, zoom in and fit view. Replaces React Flow's own * ``, whose buttons ignore the theme. Render inside ``. */ export default function CanvasControls({ onUndo, onRedo, canUndo, canRedo, }: CanvasControlsProps) { const { t } = useTranslation(); const { zoomIn, zoomOut, fitView } = useReactFlow(); const zoom = useStore((state) => state.transform[2]); return ( zoomOut({ duration: ZOOM_DURATION_MS })} label={t('agents.workflow.zoomOut')} icon={Minus} /> {Math.round(zoom * 100)}% zoomIn({ duration: ZOOM_DURATION_MS })} label={t('agents.workflow.zoomIn')} icon={Plus} /> fitView({ padding: 0.2, maxZoom: 0.8, duration: ZOOM_DURATION_MS }) } label={t('agents.workflow.fitView')} icon={Maximize} /> ); }