@@ -8,7 +8,7 @@ import useForceUpdate from './useForceUpdate';
8
8
import LinkControls from './LinkControls' ;
9
9
import getLinkComponent from './getLinkComponent' ;
10
10
import { localPoint } from '@visx/event' ;
11
- import { useTooltip , useTooltipInPortal , TooltipWithBounds } from '@visx/tooltip' ;
11
+ import { useTooltip , useTooltipInPortal , TooltipWithBounds , defaultStyles } from '@visx/tooltip' ;
12
12
import { onHover , onHoverExit } from '../actions/actions' ;
13
13
import { useStoreContext } from '../store' ;
14
14
@@ -106,17 +106,15 @@ export default function ComponentMap({
106
106
107
107
const { containerRef, TooltipInPortal } = useTooltipInPortal ( ) ;
108
108
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
+ } ;
120
118
121
119
122
120
// controls for the map
@@ -180,6 +178,19 @@ export default function ComponentMap({
180
178
left = node . y ;
181
179
}
182
180
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
+
183
194
return (
184
195
< Group top = { top } left = { left } key = { key } >
185
196
{ node . depth === 0 && (
@@ -241,16 +252,17 @@ export default function ComponentMap({
241
252
</ Tree >
242
253
</ Group >
243
254
</ svg >
244
- tooltipOpen && tooltipData && (
255
+ { tooltipOpen && tooltipData && (
245
256
< TooltipInPortal
246
257
// set this to random so it correctly updates with parent bounds
247
258
key = { Math . random ( ) }
248
259
top = { tooltipTop }
249
260
left = { tooltipLeft }
261
+ style = { tooltipStyles }
250
262
>
251
263
Tooltip Data: < strong > { tooltipData } </ strong >
252
264
</ TooltipInPortal >
253
- )
265
+ ) }
254
266
</ div >
255
267
) ;
256
268
}
0 commit comments