Skip to content

Commit 71417cf

Browse files
committed
(modify) Changed root node color to orange gradient
2 parents 7bde013 + de90b1a commit 71417cf

File tree

12 files changed

+46
-16
lines changed

12 files changed

+46
-16
lines changed

src/app/actions/actions.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,9 @@ export const deleteTab = tab => ({
7777
export const resetSlider = () => ({
7878
type: types.SLIDER_ZERO,
7979
});
80+
81+
export const onHover = () => ({
82+
type: types.ON_HOVER,
83+
//the payload should be something to relate the component we're hovering and highlight that component on the DOM
84+
payload: 'PAYLOAD FROM onHover inside of action.ts'
85+
})

src/app/components/AtomsRelationship.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function Node({ node }) {
9292
fontSize={9}
9393
fontFamily="Arial"
9494
textAnchor="middle"
95-
y="-20"
95+
y = "-20"
9696
style={{ pointerEvents: 'none' }}
9797
fill={isParent ? white : blue}
9898
>

src/app/components/ComponentMap.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import React, { useEffect, useCallback } from 'react';
88
import * as d3 from 'd3';
9+
import { useStoreContext } from '../store'
10+
import { onHover } from '../actions/actions'
911

1012
interface componentMapProps {
1113
x: number;
@@ -22,7 +24,6 @@ const ComponentMap = (props: componentMapProps) => {
2224
let lastSnap: number | null = null;
2325
if (viewIndex < 0) lastSnap = snapshots.length - 1;
2426
else lastSnap = viewIndex;
25-
2627
//external constants
2728
const width: any = '100vw';
2829
const height: any = '100vh';
@@ -34,6 +35,7 @@ const ComponentMap = (props: componentMapProps) => {
3435
return makeChart(data);
3536
}, [data]);
3637

38+
const [{ tabs, currentTab }, dispatch] = useStoreContext();
3739
const makeChart = useCallback(
3840
(data) => {
3941
// Establish Constants
@@ -145,10 +147,12 @@ const ComponentMap = (props: componentMapProps) => {
145147

146148
//TODO -> Alter incoming snapshots so there is useful data to show on hover.
147149
nodeEnter.on('mouseover', function (d: any, i: number): any {
148-
150+
//onHover is an action in progress
151+
dispatch(onHover());
149152
d3.select(this)
150153
.append('text')
151154
.text(() => {
155+
//i want to return to the node in d3 the values listed in a more readable way. Right now it's just a horizontal line of text
152156
return JSON.stringify(d.data.state);
153157
})
154158
.attr('x', -25)
@@ -158,6 +162,8 @@ const ComponentMap = (props: componentMapProps) => {
158162
.attr('stroke', 'white')
159163
.attr('stroke-width', .5)
160164
.attr('id', `popup${i}`);
165+
166+
161167

162168
});
163169
nodeEnter.on('mouseout', function (d: any, i: number): any {

src/app/components/StateRoute.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import PerfView from './PerfView';
1717
import AtomsRelationship from './AtomsRelationship.jsx';
1818
import Example from './AtomsRelationship.jsx';
1919
import { ParentSize } from '@visx/responsive'
20+
import { Console } from 'console';
21+
2022

2123
const History = require('./History').default;
2224

src/app/constants/actionTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ export const NEW_SNAPSHOTS = 'NEW_SNAPSHOTS';
1313
export const SET_TAB = 'SET_TAB';
1414
export const DELETE_TAB = 'DELETE_TAB';
1515
export const SLIDER_ZERO = 'SLIDER_ZERO';
16+
export const ON_HOVER = 'ON_HOVER';

src/app/containers/MainContainer.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const mixpanel = require("mixpanel").init("12fa2800ccbf44a5c36c37bc9776e4c0", {
2323
function MainContainer(): any {
2424
const [store, dispatch] = useStoreContext();
2525
const { tabs, currentTab, port: currentPort } = store;
26-
2726
// add event listeners to background script
2827
useEffect(() => {
2928
// only open port once
@@ -127,7 +126,6 @@ function MainContainer(): any {
127126
snapshots,
128127
hierarchy,
129128
} = tabs[currentTab];
130-
131129
// if viewIndex is -1, then use the sliderIndex instead
132130
const snapshotView = viewIndex === -1 ? snapshots[sliderIndex] : snapshots[viewIndex];
133131
// cleaning hierarchy and snapshotView from stateless data

src/app/reducers/mainReducer.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint-disable prefer-const */
33
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
44
/* eslint-disable no-param-reassign */
5-
import produce from 'immer';
5+
import {produce, original} from 'immer';
66
import * as types from '../constants/actionTypes.ts';
77

88
export default (state, action) => produce(state, draft => {
@@ -39,19 +39,28 @@ export default (state, action) => produce(state, draft => {
3939
};
4040

4141
switch (action.type) {
42+
case types.ON_HOVER: {
43+
port.postMessage({
44+
action: 'onHover',
45+
payload: 'payload from Reducer ON_HOVER',
46+
tabId: currentTab,
47+
})
48+
break;
49+
}
50+
4251
case types.MOVE_BACKWARD: {
4352
if (snapshots.length > 0 && sliderIndex > 0) {
4453
const newIndex = sliderIndex - 1;
4554
// eslint-disable-next-line max-len
4655
// finds the name by the newIndex parsing through the hierarchy to send to background.js the current name in the jump action
4756
const nameFromIndex = findName(newIndex, hierarchy);
48-
4957
port.postMessage({
5058
action: 'jumpToSnap',
5159
payload: snapshots[newIndex],
5260
index: newIndex,
5361
name: nameFromIndex,
5462
tabId: currentTab,
63+
newProp: 'newPropFromReducer'
5564
});
5665
clearInterval(intervalId);
5766

src/backend/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ window.addEventListener('message', ({ data: { action, payload } }: MsgData) => {
4949
timeJump(payload, true); // * This sets state with given payload
5050
// Get the pathname from payload and add new entry to browser history
5151
// MORE: https://developer.mozilla.org/en-US/docs/Web/API/History/pushState
52-
5352
// try to modify workInProgress tree from here
5453
// window.history.pushState('', '', getRouteURL(payload));
5554
break;
@@ -59,6 +58,9 @@ window.addEventListener('message', ({ data: { action, payload } }: MsgData) => {
5958
case 'setPause':
6059
mode.paused = payload;
6160
break;
61+
case 'onHover':
62+
// console.log('WE MADE IT ALL THE WAY FROM THE FRONTEND! HERE\'S THE PAYLOAD:', payload);
63+
break;
6264
default:
6365
break;
6466
}

src/backend/linkFiber.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,9 @@ if (window[`$recoilDebugStates`]) {
6767
function sendSnapshot(snap: Snapshot, mode: Mode): void {
6868
// Don't send messages while jumping or while paused
6969
if (mode.jumping || mode.paused) return;
70-
7170
if (!snap.tree) {
7271
snap.tree = new Tree('root', 'root');
7372
}
74-
7573
const payload = snap.tree.cleanTreeCopy();
7674

7775
if (isRecoil) {
@@ -181,6 +179,7 @@ function createTree(
181179
fromSibling = false
182180
) {
183181
// Base case: child or sibling pointed to null
182+
184183
if (!currentFiber) return null;
185184
if (!tree) return tree;
186185

@@ -267,6 +266,7 @@ function createTree(
267266
stateNode.state,
268267
stateNode
269268
);
269+
270270
newState = stateNode.state;
271271
componentFound = true;
272272
}
@@ -374,7 +374,7 @@ function createTree(
374374
} else {
375375
newNode = tree;
376376
}
377-
377+
378378
// Recurse on children
379379
if (child && !circularComponentTable.has(child)) {
380380
// If this node had state we appended to the children array,
@@ -408,11 +408,8 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
408408
const devTools = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
409409
const reactInstance = devTools ? devTools.renderers.get(1) : null;
410410
fiberRoot = devTools.getFiberRoots(1).values().next().value;
411-
412-
const throttledUpdateSnapshot = throttle(
413-
() => updateSnapShotTree(snap, mode),
414-
70
415-
);
411+
412+
const throttledUpdateSnapshot = throttle(() => updateSnapShotTree(snap, mode), 70);
416413
document.addEventListener('visibilitychange', onVisibilityChange);
417414
if (reactInstance && reactInstance.version) {
418415
devTools.onCommitFiberRoot = (function (original) {

src/backend/timeJump.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Console } from 'console';
12
/* eslint-disable @typescript-eslint/no-unused-vars */
23
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
34
/* eslint-disable max-len */

0 commit comments

Comments
 (0)