Skip to content

Commit 1c1ef37

Browse files
committed
(add) Dispatch actions onHover and useStoreContext added to AtomsRelationship tab
1 parent e39a4e3 commit 1c1ef37

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

src/app/components/AtomsRelationship.tsx

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { Cluster, hierarchy } from '@visx/hierarchy';
55
import { LinkVertical } from '@visx/shape';
66
import { LinearGradient } from '@visx/gradient';
77
import { StateRouteProps} from './StateRoute'
8+
import { onHover } from '../actions/actions'
9+
import { useStoreContext } from '../store'
810
import Legend from './AtomsRelationshipLegend'
911

1012
export const blue = '#acdbdf';
@@ -39,7 +41,7 @@ interface selectorsCache {
3941

4042

4143
const clusterData : clusterShape = {};
42-
const selectorsCache :selectorsCache = {}
44+
const selectorsCache :selectorsCache = {};
4345

4446
let initialFire = false
4547
function clusterDataPopulate(props:StateRouteProps) {
@@ -122,6 +124,7 @@ function reorganizedCompObj(props) {
122124
}
123125

124126
function Node({ node }) {
127+
const [dispatch] = useStoreContext();
125128
const selector = node.depth === 1 && node.height === 2
126129
const isRoot = node.depth === 0;
127130
const isParent = !!node.children;
@@ -136,9 +139,14 @@ function Node({ node }) {
136139
r={12}
137140
fill={isParent ? orange : blue}
138141
stroke={isParent ? orange : blue}
139-
// onClick={() => {
140-
// alert(`clicked: ${JSON.stringify(node.data.name)}`);
141-
// }}
142+
onMouseEnter={()=> {
143+
console.log('hi')
144+
// if(Object.keys(node.data.recoilDomNode).length > 0){
145+
// dispatch(onHover(node.data.recoilDomNode[node.data.name]))
146+
// } else {
147+
// dispatch(onHover(node.data.rtid))
148+
// }
149+
}}
142150
/>
143151
)}
144152
<text
@@ -191,16 +199,23 @@ function RootNode({ node }) {
191199
}
192200

193201
function SelectorNode({ node }) {
202+
const [dispatch] = useStoreContext();
194203
return (
195204
<Group top={node.y} left={node.x}>
196205
{node.depth !== 0 && (
197206
<circle
198207
r={12}
199208
fill={selectWhite}
200209
stroke={selectWhite}
201-
// onClick={() => {
202-
// alert(`clicked: ${JSON.stringify(node.data.name)}`);
203-
// }}
210+
onMouseEnter={()=> {
211+
212+
console.log('hi')
213+
// if(Object.keys(node.data.recoilDomNode).length > 0){
214+
// dispatch(onHover(node.data.recoilDomNode[node.data.name]))
215+
// } else {
216+
// dispatch(onHover(node.data.rtid))
217+
// }
218+
}}
204219
/>
205220
)}
206221
<text
@@ -262,11 +277,12 @@ export default function Example({
262277
stroke={merlinsbeard}
263278
strokeWidth="1"
264279
strokeOpacity={0.2}
265-
fill="none"
280+
fill="none"
266281
/>
267282
))}
268283
{cluster.descendants().map((node, i) => (
269-
<Node key={`cluster-node-${i}`} node={node} />
284+
<Node key={`cluster-node-${i}`}
285+
node={node} />
270286
))}
271287
</Group>
272288
)}

0 commit comments

Comments
 (0)