/** * ShapeRenderer — Renders individual shapes as SVG elements. * * Supports: rect, ellipse, line, text */ import type { CanvasShapeClient } from 'deepspace' interface ShapeRendererProps { shape: CanvasShapeClient isSelected: boolean onMouseDown: (e: React.MouseEvent, shapeId: string) => void } const SELECTION_PADDING = 4 export function ShapeRenderer({ shape, isSelected, onMouseDown }: ShapeRendererProps) { const fill = (shape.props.fill as string) ?? 'transparent' const stroke = (shape.props.stroke as string) ?? '#6366f1' const strokeWidth = (shape.props.strokeWidth as number) ?? 2 const handleMouseDown = (e: React.MouseEvent) => { e.stopPropagation() onMouseDown(e, shape.id) } return ( {/* Selection outline */} {isSelected && ( )} {/* Shape */} {shape.type === 'rect' && ( )} {shape.type === 'ellipse' && ( )} {shape.type === 'line' && ( )} {shape.type === 'text' && ( <> {(shape.props.text as string) ?? 'Text'} )} ) }