@@ -5,6 +5,7 @@ import { XCircle } from 'lucide-react'; // <<< Import XCircle
55import { useDrag } from 'react-dnd' ;
66import { getEmptyImage } from 'react-dnd-html5-backend' ;
77import useGraphStore from './store/graphStore.jsx' ;
8+ import { getTextColor } from './utils/colorUtils' ;
89// import './GraphListItem.css'; // We'll create this later
910
1011const SPAWNABLE_NODE = 'spawnable_node' ;
@@ -21,7 +22,7 @@ const GraphListItem = forwardRef(({
2122} , ref ) => {
2223 const [ isHovered , setIsHovered ] = useState ( false ) ;
2324 const nodePrototypes = useGraphStore ( state => state . nodePrototypes ) ;
24-
25+
2526 // Get the defining node's name for fallback matching
2627 const definingNodeName = useMemo ( ( ) => {
2728 const definingNodeId = graphData . definingNodeIds ?. [ 0 ] ;
@@ -31,10 +32,10 @@ const GraphListItem = forwardRef(({
3132 }
3233 return null ;
3334 } , [ graphData . definingNodeIds , nodePrototypes ] ) ;
34-
35+
3536 const [ { isDragging } , drag , preview ] = useDrag ( ( ) => ( {
3637 type : SPAWNABLE_NODE ,
37- item : {
38+ item : {
3839 prototypeId : graphData . definingNodeIds ?. [ 0 ] ,
3940 nodeName : definingNodeName // Include node name for fallback matching
4041 } ,
@@ -60,7 +61,7 @@ const GraphListItem = forwardRef(({
6061 const handleDoubleClick = useCallback ( ( ) => {
6162 // <<< Remove Log for double click >>>
6263 // console.log(`[GraphListItem ${graphData.id}] handleDoubleClick called, calling onToggleExpand.`);
63- onToggleExpand ?. ( graphData . id ) ;
64+ onToggleExpand ?. ( graphData . id ) ;
6465 // Potentially call onDoubleClick prop if needed for other actions
6566 // onDoubleClick?.(graphData.id);
6667 } , [ graphData . id , onToggleExpand ] ) ; // <<< Add dependencies
@@ -82,12 +83,12 @@ const GraphListItem = forwardRef(({
8283 // aspectRatio: isExpanded ? '1 / 1' : undefined, // REMOVE aspect-ratio
8384 // FIX: Set static background/color, only border changes
8485 backgroundColor : graphData . color || 'maroon' , // Always maroon
85- color : '#bdb5b5' , // Always light text
86+ color : getTextColor ( graphData . color || 'maroon' ) ,
8687 // FIX: Use margin for spacing, remove marginBottom
8788 // marginBottom: '10px',
8889 margin : '5px 0' , // Equal top/bottom margin
8990 // FIX: Increase border radius
90- borderRadius : '12px' ,
91+ borderRadius : '12px' ,
9192 boxSizing : 'border-box' ,
9293 cursor : 'pointer' ,
9394 display : 'flex' ,
@@ -113,13 +114,13 @@ const GraphListItem = forwardRef(({
113114 width : '85%' ,
114115 // height: '80%', // REMOVE fixed height
115116 // FIX: Animate maxHeight and opacity directly
116- maxHeight : isExpanded ? '80%' : '0px' ,
117+ maxHeight : isExpanded ? '80%' : '0px' ,
117118 opacity : isExpanded ? 1 : 0 ,
118119 marginTop : '0' ,
119120 marginBottom : '0' ,
120121 backgroundColor : '#bdb5b5' ,
121122 borderRadius : '4px' ,
122- overflow : 'hidden' ,
123+ overflow : 'hidden' ,
123124 display : 'flex' ,
124125 alignItems : 'center' ,
125126 justifyContent : 'center' ,
@@ -145,21 +146,21 @@ const GraphListItem = forwardRef(({
145146 title = { graphData . name } // Tooltip with full name
146147 >
147148 { /* Graph Name - Add padding here */ }
148- < div
149+ < div
149150 style = { {
150- fontWeight : 'bold' ,
151- whiteSpace : 'nowrap' ,
152- overflow : 'hidden' ,
153- textOverflow : 'ellipsis' ,
154- padding : isExpanded ? '5px 10px' : '10px' ,
155- textAlign : 'center' ,
156- width : '100%' ,
157- boxSizing : 'border-box' ,
158- // FIX: Remove auto margins when expanded
159- marginTop : isExpanded ? '0' : 'auto' ,
160- marginBottom : isExpanded ? '10px' : 'auto' ,
161- userSelect : 'none' ,
162- fontFamily : "'EmOne', sans-serif" ,
151+ fontWeight : 'bold' ,
152+ whiteSpace : 'nowrap' ,
153+ overflow : 'hidden' ,
154+ textOverflow : 'ellipsis' ,
155+ padding : isExpanded ? '5px 10px' : '10px' ,
156+ textAlign : 'center' ,
157+ width : '100%' ,
158+ boxSizing : 'border-box' ,
159+ // FIX: Remove auto margins when expanded
160+ marginTop : isExpanded ? '0' : 'auto' ,
161+ marginBottom : isExpanded ? '10px' : 'auto' ,
162+ userSelect : 'none' ,
163+ fontFamily : "'EmOne', sans-serif" ,
163164 } }
164165 >
165166 { graphData . name }
@@ -168,15 +169,15 @@ const GraphListItem = forwardRef(({
168169 { /* Conditional Preview Area - Animate container directly */ }
169170 < div style = { previewContainerStyle } >
170171 { /* <div style={previewWrapperStyle}> REMOVE Wrapper */ }
171- { /* Render the actual preview only when expanded to avoid rendering cost? */ }
172- { isExpanded && (
173- < GraphPreview
174- nodes = { graphData . nodes }
175- edges = { graphData . edges }
176- width = { itemStyle . width === '100%' ? 100 : ( currentItemWidth ) * 0.85 }
177- height = { itemStyle . width === '100%' ? 100 : ( currentItemWidth ) * 0.80 }
178- />
179- ) }
172+ { /* Render the actual preview only when expanded to avoid rendering cost? */ }
173+ { isExpanded && (
174+ < GraphPreview
175+ nodes = { graphData . nodes }
176+ edges = { graphData . edges }
177+ width = { itemStyle . width === '100%' ? 100 : ( currentItemWidth ) * 0.85 }
178+ height = { itemStyle . width === '100%' ? 100 : ( currentItemWidth ) * 0.80 }
179+ />
180+ ) }
180181 { /* </div> */ }
181182 </ div >
182183
0 commit comments