@@ -9,8 +9,8 @@ import { GRID_SIZE, G } from './grid';
99
1010/** Node dimension constants (grid-aligned) */
1111export const NODE = {
12- /** Base width: 10 grid units = 100px */
13- baseWidth : G . x10 ,
12+ /** Base width: 8 grid units = 80px */
13+ baseWidth : G . px ( 8 ) ,
1414 /** Base height: 4 grid units = 40px */
1515 baseHeight : G . x4 ,
1616 /** Spacing between ports: 2 grid units = 20px */
@@ -81,7 +81,8 @@ export function calculateNodeDimensions(
8181 inputCount : number ,
8282 outputCount : number ,
8383 pinnedParamCount : number ,
84- rotation : number
84+ rotation : number ,
85+ typeName ?: string
8586) : { width : number ; height : number } {
8687 const isVertical = rotation === 1 || rotation === 3 ;
8788 const maxPortsOnSide = Math . max ( inputCount , outputCount ) ;
@@ -90,12 +91,15 @@ export function calculateNodeDimensions(
9091 // Pinned params height: border(1) + padding(10) + rows(20 each) + gaps(4 between)
9192 const pinnedParamsHeight = pinnedParamCount > 0 ? 7 + 24 * pinnedParamCount : 0 ;
9293
93- // Width: base, name estimate, pinned params minimum, port dimension (if vertical)
94- const nameWidth = name . length * 6 + 24 ;
94+ // Width: base, name estimate, type name estimate, pinned params minimum, port dimension (if vertical)
95+ // Name uses 10px font (~5px per char), type uses 8px font (~4px per char), plus padding for node margins
96+ const nameWidth = name . length * 5 + 20 ;
97+ const typeWidth = typeName ? typeName . length * 4 + 20 : 0 ;
9598 const pinnedParamsWidth = pinnedParamCount > 0 ? 160 : 0 ;
9699 const width = snapTo2G ( Math . max (
97100 NODE . baseWidth ,
98101 nameWidth ,
102+ typeWidth ,
99103 pinnedParamsWidth ,
100104 isVertical ? minPortDimension : 0
101105 ) ) ;
0 commit comments