Skip to content

Commit 55a9fdc

Browse files
committed
Include type name in node width calculation
1 parent 4460d80 commit 55a9fdc

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/lib/components/FlowCanvas.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,8 @@
392392
graphNode.inputs.length,
393393
graphNode.outputs.length,
394394
pinnedParamCount,
395-
rotation
395+
rotation,
396+
typeDef?.name
396397
);
397398
398399
// If node exists, update data but don't preserve selection here

src/lib/components/nodes/BaseNode.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@
142142
data.inputs.length,
143143
data.outputs.length,
144144
pinnedCount,
145-
rotation
145+
rotation,
146+
typeDef?.name
146147
));
147148
const nodeWidth = $derived(nodeDimensions.width);
148149
const nodeHeight = $derived(nodeDimensions.height);

src/lib/constants/dimensions.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
// Width: base, name estimate, type name estimate, pinned params minimum, port dimension (if vertical)
95+
// Name uses 10px font (~6px per char), type uses 8px font (~5px per char)
9496
const nameWidth = name.length * 6 + 24;
97+
const typeWidth = typeName ? typeName.length * 5 + 24 : 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

Comments
 (0)