Skip to content

Commit dcfd648

Browse files
committed
MESSAGE
> > Co-authored-by: kev-ngo <[email protected]> Co-authored-by: CourageWolf <[email protected]> Co-authored-by: DennisLpz <[email protected]> Co-authored-by: demircaner <[email protected]>
1 parent 009f5d4 commit dcfd648

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

src/app/components/ComponentMap.tsx

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import useForceUpdate from './useForceUpdate';
88
import LinkControls from './LinkControls';
99
import getLinkComponent from './getLinkComponent';
1010
import { localPoint } from '@visx/event';
11-
import { useTooltip, useTooltipInPortal, TooltipWithBounds } from '@visx/tooltip';
11+
import { useTooltip, useTooltipInPortal, TooltipWithBounds, defaultStyles } from '@visx/tooltip';
1212
import { onHover, onHoverExit } from '../actions/actions';
1313
import { useStoreContext } from '../store';
1414

@@ -106,17 +106,15 @@ export default function ComponentMap({
106106

107107
const { containerRef, TooltipInPortal } = useTooltipInPortal();
108108

109-
//mousing controls
110-
const handleMouseOver = (event) => {
111-
console.log("mouse entered");
112-
const coords = localPoint(event.target.ownerSVGElement, event);
113-
console.log("I'm coords", coords);
114-
showTooltip({
115-
tooltipLeft: coords.x,
116-
tooltipTop: coords.y,
117-
tooltipData: "test"
118-
});
119-
}
109+
const tooltipStyles = {
110+
...defaultStyles,
111+
minWidth: 60,
112+
backgroundColor: 'rgba(0,0,0,0.9)',
113+
color: 'white',
114+
fontSize: '14px',
115+
lineHeight: '18px',
116+
fontFamily: 'Roboto',
117+
};
120118

121119

122120
// controls for the map
@@ -180,6 +178,19 @@ export default function ComponentMap({
180178
left = node.y;
181179
}
182180

181+
//mousing controls
182+
const handleMouseOver = (event) => {
183+
() => dispatch(onHover(node.data.rtid));
184+
const coords = localPoint(event.target.ownerSVGElement, event);
185+
console.log("I'm node.data.rtid", node.data.rtid);
186+
showTooltip({
187+
tooltipLeft: coords.x,
188+
tooltipTop: coords.y,
189+
tooltipData: "test"
190+
});
191+
}
192+
193+
183194
return (
184195
<Group top={top} left={left} key={key}>
185196
{node.depth === 0 && (
@@ -241,16 +252,17 @@ export default function ComponentMap({
241252
</Tree>
242253
</Group>
243254
</svg>
244-
tooltipOpen && tooltipData && (
255+
{tooltipOpen && tooltipData && (
245256
<TooltipInPortal
246257
// set this to random so it correctly updates with parent bounds
247258
key={Math.random()}
248259
top={tooltipTop}
249260
left={tooltipLeft}
261+
style={tooltipStyles}
250262
>
251263
Tooltip Data: <strong>{tooltipData}</strong>
252264
</TooltipInPortal>
253-
)
265+
)}
254266
</div>
255267
);
256268
}

0 commit comments

Comments
 (0)