Skip to content

Commit bac5f56

Browse files
committed
added reducer state data to tool tip display
1 parent d5883b8 commit bac5f56

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

src/app/components/StateRoute/AxMap/Ax.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useTooltip, useTooltipInPortal, defaultStyles } from '@visx/tooltip';
99
import ToolTipDataDisplay from './ToolTipDataDisplay';
1010
import { ToolTipStyles } from '../../../FrontendTypes';
1111
import { localPoint } from '@visx/event';
12+
import { toggleExpanded, setCurrentTabInApp } from '../../../slices/mainSlice';
1213

1314
const defaultMargin = {
1415
top: 30,
@@ -293,17 +294,16 @@ export default function AxTree(props) {
293294
<Group top={top} left={left} key={key} className='rect'>
294295
{node.depth === 0 && (
295296
<rect
296-
className={node.children ? 'compMapParent' : 'compMapChild'}
297+
className={'compMapRoot'}
297298
height={height}
298299
width={width}
299300
y={-height / 2}
300301
x={-width / 2}
301-
fill="url('#parent-gradient')"
302302
strokeWidth={1.5}
303303
strokeOpacity='1'
304-
rx={node.children ? 4 : 10}
304+
rx={10}
305305
onClick={() => {
306-
node.data.isExpanded = !node.data.isExpanded;
306+
dispatch(toggleExpanded(node.data));
307307
hideTooltip();
308308
}}
309309
/>
@@ -315,12 +315,11 @@ export default function AxTree(props) {
315315
width={width}
316316
y={-height / 2}
317317
x={-width / 2}
318-
fill="url('#parent-gradient')"
319318
strokeWidth={1.5}
320319
strokeOpacity='1'
321-
rx={node.children ? 4 : 10}
320+
rx={10}
322321
onClick={() => {
323-
node.data.isExpanded = !node.data.isExpanded;
322+
dispatch(toggleExpanded(node.data));
324323
hideTooltip();
325324
}}
326325
// Mouse Enter Rect (Component Node) -----------------------------------------------------------------------

src/app/components/StateRoute/ComponentMap/ComponentMap.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,23 @@ export default function ComponentMap({
260260
<svg ref={containerRef} width={totalWidth} height={totalHeight + 0}>
261261
<LinearGradient id='root-gradient' from='#488689' to='#3c6e71' />
262262
<LinearGradient id='parent-gradient' from='#488689' to='#3c6e71' />
263+
<rect
264+
className='componentMapContainer'
265+
onClick={() => {
266+
hideTooltip();
267+
}}
268+
width={sizeWidth / aspect}
269+
height={sizeHeight / aspect + 0}
270+
rx={14}
271+
/>
263272
<Group transform={`scale(${aspect})`} top={margin.top} left={margin.left}>
264273
<Tree
265274
root={hierarchy(startNode, (d) => (d.isExpanded ? d.children : null))}
266275
size={[sizeWidth / aspect, sizeHeight / aspect]}
267276
separation={(a, b) => (a.parent === b.parent ? 0.5 : 0.5) / a.depth}
268277
>
269278
{(tree) => (
270-
<Group top={origin.y + 35} left={origin.x + 50 / aspect}>
279+
<Group top={origin.y + 35} left={origin.x + 50}>
271280
{tree.links().map((link, i) => {
272281
const linkName = link.source.data.name;
273282
const propsObj = link.source.data.componentData.props;
@@ -448,7 +457,7 @@ export default function ComponentMap({
448457
}
449458
}
450459
} else {
451-
aspect = Math.max(aspect, 1);
460+
aspect = Math.max(aspect, 0.8);
452461
}
453462

454463
// mousing controls & Tooltip display logic

src/app/components/StateRoute/ComponentMap/ToolTipDataDisplay.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,15 @@ const ToolTipDataDisplay = ({ data }) => {
3838
};
3939

4040
const formatReducerData = (reducerStates) => {
41-
// Check if reducerStates exists and is an array
42-
if (!Array.isArray(reducerStates)) {
41+
// Check if reducerStates exists and is an object
42+
if (!reducerStates || typeof reducerStates !== 'object') {
4343
return {};
4444
}
4545

46-
return reducerStates.reduce((acc, reducer) => {
46+
// Handle both array and object formats
47+
const statesArray = Array.isArray(reducerStates) ? reducerStates : Object.values(reducerStates);
48+
49+
return statesArray.reduce((acc, reducer) => {
4750
// Add additional type checking for reducer object
4851
if (reducer && typeof reducer === 'object') {
4952
acc[reducer.hookName || 'Reducer'] = reducer.state;
@@ -67,9 +70,11 @@ const ToolTipDataDisplay = ({ data }) => {
6770
if (isReducer && parsedContent) {
6871
// Only try to format if we have valid content
6972
const formattedData = formatReducerData(parsedContent);
73+
console.log('formatted data', formattedData);
7074

7175
// Check if we have any formatted data to display
7276
if (Object.keys(formattedData).length === 0) {
77+
console.log('formatted data length', Object.keys(formattedData).length);
7378
return null;
7479
}
7580

src/app/styles/layout/_stateContainer.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
.app-content,
99
.app-body {
1010
height: 100%;
11-
overflow: hidden; /* Prevent double scrollbars */
11+
overflow: hidden;
1212
}
1313

1414
.main-navbar-container--structural {

0 commit comments

Comments
 (0)