@@ -8,6 +8,7 @@ import { useCallback, useState } from 'react';
88import { DEFAULT_NODE_HEADER_HEIGHT , ZOOM_THRESHOLD } from '@/utilities/constants' ;
99import { InternalNode } from '@/types/internal' ;
1010import { PlusWithSquare } from '@/components/icons/plus-with-square' ;
11+ import { ChevronCollapse } from '@/components/icons/chevron-collapse' ;
1112import { NodeBorder } from '@/components/node/node-border' ;
1213import { FieldList } from '@/components/field/field-list' ;
1314import { NodeType } from '@/types' ;
@@ -102,9 +103,14 @@ const NodeWithFields = styled.div<{ visibility: string }>`
102103 visibility: ${ props => props . visibility } ;
103104` ;
104105
105- const AddNewFieldIconButtonButton = styled ( DiagramIconButton ) `
106+ const TitleControlsContainer = styled . div `
106107 margin-left: auto;
107108 margin-right: ${ spacing [ 200 ] } px;
109+ display: flex;
110+ gap: ${ spacing [ 50 ] } px;
111+ & > * {
112+ flex: 0 0 auto;
113+ }
108114` ;
109115
110116export const Node = ( {
@@ -119,7 +125,7 @@ export const Node = ({
119125
120126 const [ isHovering , setHovering ] = useState ( false ) ;
121127
122- const { onClickAddFieldToNode : addFieldToNodeClickHandler } = useEditableDiagramInteractions ( ) ;
128+ const { onClickAddFieldToNode : addFieldToNodeClickHandler , onNodeExpandToggle } = useEditableDiagramInteractions ( ) ;
123129
124130 const onClickAddFieldToNode = useCallback (
125131 ( event : React . MouseEvent < HTMLButtonElement > ) => {
@@ -129,6 +135,13 @@ export const Node = ({
129135 [ addFieldToNodeClickHandler , id ] ,
130136 ) ;
131137
138+ const handleNodeExpandToggle = useCallback (
139+ ( event : React . MouseEvent < HTMLButtonElement > ) => {
140+ onNodeExpandToggle ?.( event , id ) ;
141+ } ,
142+ [ onNodeExpandToggle , id ] ,
143+ ) ;
144+
132145 const getAccent = ( ) => {
133146 if ( disabled && ! isHovering ) {
134147 return theme . node . disabledAccent ;
@@ -210,11 +223,22 @@ export const Node = ({
210223 < Icon fill = { theme . node . headerIcon } glyph = "Drag" />
211224 </ NodeHeaderIcon >
212225 < NodeHeaderTitle > { title } </ NodeHeaderTitle >
213- { addFieldToNodeClickHandler && (
214- < AddNewFieldIconButtonButton aria-label = "Add Field" onClick = { onClickAddFieldToNode } title = "Add Field" >
215- < PlusWithSquare />
216- </ AddNewFieldIconButtonButton >
217- ) }
226+ < TitleControlsContainer >
227+ { addFieldToNodeClickHandler && (
228+ < DiagramIconButton aria-label = "Add Field" onClick = { onClickAddFieldToNode } title = "Add Field" >
229+ < PlusWithSquare />
230+ </ DiagramIconButton >
231+ ) }
232+ { onNodeExpandToggle && (
233+ < DiagramIconButton
234+ aria-label = "Toggle Expand / Collapse Fields"
235+ onClick = { handleNodeExpandToggle }
236+ title = "Toggle Expand / Collapse Fields"
237+ >
238+ < ChevronCollapse />
239+ </ DiagramIconButton >
240+ ) }
241+ </ TitleControlsContainer >
218242 </ NodeHeader >
219243 < FieldList nodeId = { id } nodeType = { type as NodeType } isHovering = { isHovering } fields = { fields } />
220244 </ NodeWithFields >
0 commit comments