Skip to content

Commit 1ed9525

Browse files
committed
improvement(workflow): give a container one source for its own gutter
The four paddings and the header height existed twice: as `CONTAINER_DIMENSIONS`, which sizes a container and clamps its children, and again as Tailwind literals in `subflow-node-view`, which draws the header and the content box. Nothing kept them in step and they had already drifted — the view rendering a 40px header against a constant claiming 50, so children were clamped 10px below where the header actually ends. The view now renders from the constants, and the constant follows the DOM at 40. Match the bottom gutter to the right at 80. The two edges that carry chrome are now the two that are wider: the container's output handle sits on the right, and the resize grip in the bottom-right corner spans 40px in from both, so a child at the 24px gutter width could sit underneath it. Left and top are only gutter and stay at 24.
1 parent 07a59eb commit 1ed9525

2 files changed

Lines changed: 29 additions & 16 deletions

File tree

packages/workflow-renderer/src/dimensions.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,27 +83,33 @@ export const estimateNoteBlockHeight = (content: string) => {
8383
/**
8484
* A container's box, and the gutter it keeps around the blocks inside it.
8585
*
86-
* Each padding is the gap between a child's edge and the container's, and
87-
* nothing else. The header is counted once, by the child's own position, which
88-
* `clampPositionToContainer` floors at `HEADER_HEIGHT + TOP_PADDING` — so these
89-
* are the numbers you see, and three of them match because those three edges
90-
* are only gutter.
86+
* The single source for both halves of that: the layout math that sizes a
87+
* container and clamps its children, and the card's own DOM. `subflow-node-view`
88+
* renders its header and content box straight from these, so the gap the
89+
* geometry reserves is the gap the container actually paints. They used to be
90+
* separate — the same four numbers as Tailwind literals in the view — and had
91+
* already drifted, the view drawing a 40px header against a constant that
92+
* claimed 50.
9193
*
92-
* `RIGHT_PADDING` is the deliberate exception. The container's own output
93-
* handle sits on that edge, so a child needs clearance there it does not need
94-
* anywhere else. That makes it chrome rather than gutter, which is why it is
95-
* not tied to the other three.
94+
* Each padding is the gap between a child's edge and the container's, counted
95+
* once: the header is accounted for by the child's own position, which
96+
* `clampPositionToContainer` floors at `HEADER_HEIGHT + TOP_PADDING`.
97+
*
98+
* The two edges that carry chrome are wider than the two that are only gutter.
99+
* The container's output handle sits on the right, and the resize grip in the
100+
* bottom-right corner spans 40px in from both — a child at the gutter width
101+
* would sit underneath it.
96102
*/
97103
export const CONTAINER_DIMENSIONS = {
98104
DEFAULT_WIDTH: 500,
99105
DEFAULT_HEIGHT: 300,
100106
MIN_WIDTH: 400,
101107
MIN_HEIGHT: 200,
102-
HEADER_HEIGHT: 50,
108+
HEADER_HEIGHT: 40,
103109
LEFT_PADDING: 24,
104110
RIGHT_PADDING: 80,
105111
TOP_PADDING: 24,
106-
BOTTOM_PADDING: 24,
112+
BOTTOM_PADDING: 80,
107113
} as const
108114

109115
/**

packages/workflow-renderer/src/subflow/subflow-node-view.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
useStoreApi as useReactFlowStoreApi,
99
useUpdateNodeInternals,
1010
} from 'reactflow'
11-
import { BLOCK_DIMENSIONS, HANDLE_POSITIONS } from '../dimensions'
11+
import { BLOCK_DIMENSIONS, CONTAINER_DIMENSIONS, HANDLE_POSITIONS } from '../dimensions'
1212
import { OverflowSpan } from '../lib/overflow-span'
1313
import type { DiffStatus } from '../types'
1414
import {
@@ -588,8 +588,8 @@ export function SubflowNodeView({
588588
aria-label={`Select ${blockName}`}
589589
onClick={onSelect}
590590
onKeyDown={(event) => handleKeyboardActivation(event, onSelect)}
591-
className='workflow-drag-handle relative z-20 flex h-[40px] cursor-grab items-center justify-between px-2 [&:active]:cursor-grabbing'
592-
style={{ pointerEvents: 'auto' }}
591+
className='workflow-drag-handle relative z-20 flex cursor-grab items-center justify-between px-2 [&:active]:cursor-grabbing'
592+
style={{ pointerEvents: 'auto', height: CONTAINER_DIMENSIONS.HEADER_HEIGHT }}
593593
data-subflow-header=''
594594
>
595595
<div
@@ -647,9 +647,16 @@ export function SubflowNodeView({
647647
)}
648648

649649
<div
650-
className='relative z-20 h-[calc(100%-40px)] pt-4 pr-[80px] pb-4 pl-4'
650+
className='relative z-20'
651651
data-dragarea='true'
652-
style={{ pointerEvents: 'none' }}
652+
style={{
653+
pointerEvents: 'none',
654+
height: `calc(100% - ${CONTAINER_DIMENSIONS.HEADER_HEIGHT}px)`,
655+
paddingTop: CONTAINER_DIMENSIONS.TOP_PADDING,
656+
paddingRight: CONTAINER_DIMENSIONS.RIGHT_PADDING,
657+
paddingBottom: CONTAINER_DIMENSIONS.BOTTOM_PADDING,
658+
paddingLeft: CONTAINER_DIMENSIONS.LEFT_PADDING,
659+
}}
653660
>
654661
<SubflowStartView
655662
parentId={id}

0 commit comments

Comments
 (0)