fix: VariableNode size
This commit is contained in:
@@ -47,9 +47,14 @@ function coerceValue(raw: string, valueType: ValueType): string | number | boole
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function VariableNodeComponent({ id, data, selected }: Props) {
|
function VariableNodeComponent({ id, data, width, height, selected }: Props) {
|
||||||
const { updateData } = useAbstractNode<VariableNodeData>(id, data ?? {})
|
const { updateData } = useAbstractNode<VariableNodeData>(id, data ?? {})
|
||||||
|
|
||||||
|
const dimensions =
|
||||||
|
width != null && height != null && width > 0 && height > 0
|
||||||
|
? { width, height }
|
||||||
|
: undefined
|
||||||
|
|
||||||
const valueType: ValueType = data?.valueType ?? 'string'
|
const valueType: ValueType = data?.valueType ?? 'string'
|
||||||
const value = data?.value ?? DEFAULT_BY_TYPE[valueType]
|
const value = data?.value ?? DEFAULT_BY_TYPE[valueType]
|
||||||
const displayValue = typeof value === 'string' ? value : String(value)
|
const displayValue = typeof value === 'string' ? value : String(value)
|
||||||
@@ -79,7 +84,7 @@ function VariableNodeComponent({ id, data, selected }: Props) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseNode className="min-w-56 min-h-[180px]" selected={selected} handles={<OutputHandle id="out" />}>
|
<BaseNode className="min-w-56 min-h-[180px]" dimensions={dimensions} selected={selected} handles={<OutputHandle id="out" />}>
|
||||||
<BaseNodeHeaderRow icon={<Variable className="size-4" />} title={<NodeHeaderTitle nodeId={id} displayTitle={id} />} />
|
<BaseNodeHeaderRow icon={<Variable className="size-4" />} title={<NodeHeaderTitle nodeId={id} displayTitle={id} />} />
|
||||||
|
|
||||||
<BaseNodeContent>
|
<BaseNodeContent>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export function registerBuiltinNodes(): void {
|
|||||||
registerNodeType({
|
registerNodeType({
|
||||||
id: 'variable',
|
id: 'variable',
|
||||||
component: VariableNode,
|
component: VariableNode,
|
||||||
defaultStyle: { width: 224, height: 180 },
|
defaultStyle: { width: 224, height: 240 },
|
||||||
defaultData: { value: '', valueType: 'string' },
|
defaultData: { value: '', valueType: 'string' },
|
||||||
idPrefix: 'var_',
|
idPrefix: 'var_',
|
||||||
hasInput: false,
|
hasInput: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user