Skip to content

Commit 3ff6a8a

Browse files
authored
Merge pull request #16 from oslabs-beta/staging
Staging
2 parents 931670f + 4f0a948 commit 3ff6a8a

File tree

9 files changed

+117
-74
lines changed

9 files changed

+117
-74
lines changed

src/app/components/Action.jsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,26 @@ import PropTypes from 'prop-types';
33
import { changeView, changeSlider } from '../actions/actions';
44

55
/* // gabi and nate :: index and delta props were removed from Action.jsx */
6+
// viewIndex and handleonkeyDown added to props
67
const Action = props => {
78
const {
8-
selected, index, sliderIndex, dispatch, displayName, componentName, state
9+
selected, index, sliderIndex, dispatch, displayName, componentName, state, viewIndex, handleOnkeyDown,
910
} = props;
1011

1112
return (
1213
<div
14+
// Edwin: invoking keyboard functionality; functionality is in ActionContainer;
15+
onKeyDown={e => handleOnkeyDown(e, viewIndex)}
1316
className={selected ? 'action-component selected' : 'action-component'}
14-
onClick={() => dispatch(changeView(index))}
17+
onClick={() => {
18+
dispatch(changeView(index));
19+
}}
1520
role="presentation"
1621
style={index > sliderIndex ? { color: '#5f6369' } : {}}
22+
tabIndex={index}
1723
>
1824
<div className="action-component-text">
19-
{`${displayName}: ${componentName} `}
25+
{`${displayName}: ${componentName} `}
2026
</div>
2127
<button
2228
className="jump-button"
@@ -41,7 +47,9 @@ Action.propTypes = {
4147
dispatch: PropTypes.func.isRequired,
4248
displayName: PropTypes.string.isRequired,
4349
componentName: PropTypes.string.isRequired,
44-
state: PropTypes.object.isRequired
50+
state: PropTypes.object.isRequired,
51+
handleOnkeyDown: PropTypes.func.isRequired,
52+
viewIndex: PropTypes.number.isRequired,
4553
};
4654

4755
export default Action;

src/app/components/Chart.jsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
/* eslint-disable no-param-reassign */
1010
/* eslint-disable no-use-before-define */
1111
/* eslint-disable react/no-string-refs */
12+
13+
1214
import React, { Component } from 'react';
1315
import * as d3 from 'd3';
1416

@@ -72,9 +74,10 @@ class Chart extends Component {
7274

7375
const tree = d3.tree()
7476
// this assigns width of tree to be 2pi
75-
.size([2 * Math.PI, radius / 1.3])
77+
// .size([2 * Math.PI, radius / 1.3])
78+
.nodeSize([width/10, height/10])
7679
// .separation(function (a, b) { return (a.parent == b.parent ? 1 : 2) / a.depth; });
77-
.separation(function (a, b) { return (a.parent == b.parent ? 1 : 2)});
80+
.separation(function (a, b) { return (a.parent == b.parent ? 2 : 2)});
7881

7982
const d3root = tree(hierarchy);
8083

@@ -88,7 +91,10 @@ class Chart extends Component {
8891
.append('path')
8992
.attr('class', 'link')
9093
.attr('d', d3.linkRadial()
91-
.angle(d => d.x)
94+
.angle(d => {
95+
console.log('d on line 92 chart', d)
96+
return d.x
97+
})
9298
.radius(d => d.y));
9399

94100
const node = g.selectAll('.node')
@@ -105,12 +111,12 @@ class Chart extends Component {
105111
});
106112

107113
node.append('circle')
108-
.attr('r', 5)
114+
.attr('r', 15)
109115
.on('mouseover', function (d) {
110116
d3.select(this)
111117
.transition(100)
112118
.duration(20)
113-
.attr('r', 10);
119+
.attr('r', 25);
114120

115121
tooltipDiv.transition()
116122
.duration(50)
@@ -125,7 +131,7 @@ class Chart extends Component {
125131
d3.select(this)
126132
.transition()
127133
.duration(300)
128-
.attr('r', 5);
134+
.attr('r', 15);
129135

130136
tooltipDiv.transition()
131137
.duration(400)
@@ -134,14 +140,14 @@ class Chart extends Component {
134140
node
135141
.append('text')
136142
// adjusts the y coordinates for the node text
137-
.attr('dy', '-1.5em')
143+
.attr('dy', '0.5em')
138144
.attr('x', function (d) {
139145
// this positions how far the text is from leaf nodes (ones without children)
140146
// negative number before the colon moves the text of rightside nodes,
141147
// positive number moves the text for the leftside nodes
142-
return d.x < Math.PI === !d.children ? -4 : 5;
148+
return d.x < Math.PI === !d.children ? 0 : 0;
143149
})
144-
.attr('text-anchor', function (d) { return d.x < Math.PI === !d.children ? 'start' : 'end'; })
150+
.attr('text-anchor', 'middle')
145151
// this arranges the angle of the text
146152
.attr('transform', function (d) { return 'rotate(' + (d.x < Math.PI ? d.x - Math.PI / 2 : d.x + Math.PI / 2) * 1 / Math.PI + ')'; })
147153
.text(function (d) {
@@ -159,7 +165,7 @@ class Chart extends Component {
159165

160166
chartContainer.call(d3.zoom()
161167
.extent([[0, 0], [width, height]])
162-
.scaleExtent([1, 8])
168+
.scaleExtent([0, 8]) //scaleExtent([minimum scale factor, maximum scale factor])
163169
.on('zoom', zoomed));
164170

165171
function dragstarted() {

src/app/components/StateRoute.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Tree from './Tree';
1010
// eslint-disable-next-line react/prop-types
1111

1212
const StateRoute = ({ snapshot, hierarchy }) => {
13-
// gabi :: the hierarchy get set on the first click in the page, when page in refreshed we don't have a hierarchy so we need to check if hierarchy was inicialize involk render chart
13+
// gabi :: the hierarchy get set on the first click in the page, when page in refreshed we don't have a hierarchy so we need to check if hierarchy was initialize involk render chart
1414
const renderChart = () =>{
1515
if (hierarchy){
1616
return <Chart hierarchy={hierarchy} />
@@ -20,7 +20,7 @@ const StateRoute = ({ snapshot, hierarchy }) => {
2020
}
2121
}
2222

23-
// gabi :: the snapshot get set on the first click in the page, when page in refreshed we don't have a hierarchy so we need to check if snapshot was inicialize involk render chart
23+
// gabi :: the snapshot get set on the first click in the page, when page in refreshed we don't have a hierarchy so we need to check if snapshot was initialize involk render chart
2424
const renderTree = () => {
2525
if (hierarchy){
2626
return <Tree snapshot={snapshot} />

src/app/containers/ActionContainer.jsx

Lines changed: 58 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React from 'react';
44
import { diff } from 'jsondiffpatch';
55
import Action from '../components/Action';
66

7-
import { emptySnapshots } from '../actions/actions';
7+
import { emptySnapshots, changeView, changeSlider } from '../actions/actions';
88
import { useStoreContext } from '../store';
99

1010
const resetSlider = () => {
@@ -20,40 +20,65 @@ function ActionContainer() {
2020
let actionsArr = [];
2121
let hierarchyArr = [];
2222

23-
// gabi and nate :: delete function to traverse state from snapshots, now we are tranversing state from hiararchy and alsog getting infromation on display name and component name
24-
const displayArray = (obj) => {
25-
const newObj = {
26-
index: obj.index,
27-
displayName : `${obj.name}.${obj.branch}`,
28-
state: obj.stateSnapshot.children[0].state,
29-
componentName: obj.stateSnapshot.children[0].name,
30-
}
31-
hierarchyArr.push(newObj)
32-
if(obj.children){
33-
obj.children.forEach((element) => {
34-
displayArray(element)
35-
})
36-
}
23+
// gabi and nate :: delete function to traverse state from snapshots, now we are tranversing state from hiararchy and alsog getting infromation on display name and component name
24+
const displayArray = (obj) => {
25+
const newObj = {
26+
index: obj.index,
27+
displayName: `${obj.name}.${obj.branch}`,
28+
state: obj.stateSnapshot.children[0].state,
29+
componentName: obj.stateSnapshot.children[0].name,
3730
}
38-
// gabi :: the hierarchy get set on the first click in the page, when page in refreshed we don't have a hierarchy so we need to check if hierarchy was inicialize involk displayArray to display the hierarchy
39-
if (hierarchy) displayArray(hierarchy)
40-
// console.log('this is hierarchyArr', hierarchyArr)
31+
32+
hierarchyArr.push(newObj)
33+
if (obj.children) {
34+
obj.children.forEach((element) => {
35+
displayArray(element)
36+
})
37+
}
38+
}
39+
// gabi :: the hierarchy get set on the first click in the page, when page in refreshed we don't have a hierarchy so we need to check if hierarchy was inicialize involk displayArray to display the hierarchy
40+
if (hierarchy) displayArray(hierarchy)
41+
// console.log('this is hierarchyArr', hierarchyArr)
42+
43+
// Edwin: handles keyboard presses, function passes an event and index of each action-component
44+
function handleOnKeyDown(e, i) {
45+
let currIndex = i;
46+
// up array key pressed
47+
if (e.keyCode === 38) {
48+
currIndex -= 1;
49+
if (currIndex < 0) return;
50+
dispatch(changeView(currIndex));
51+
}
52+
// down arrow key pressed
53+
else if (e.keyCode === 40) {
54+
currIndex += 1;
55+
if (currIndex > hierarchyArr.length - 1) return;
56+
dispatch(changeView(currIndex));
57+
}
58+
// enter key pressed
59+
else if (e.keyCode === 13) {
60+
e.stopPropagation();
61+
dispatch(changeSlider(currIndex));
62+
}
63+
}
4164

42-
actionsArr = hierarchyArr.map((snapshot, index) => {
43-
const selected = index === viewIndex;
44-
return (
45-
<Action
46-
key={`action${index}`}
47-
index={index}
48-
state={snapshot.state}
49-
displayName={snapshot.displayName}
50-
componentName={snapshot.componentName}
51-
selected={selected}
52-
dispatch={dispatch}
53-
sliderIndex={sliderIndex}
54-
/>
55-
);
56-
});
65+
actionsArr = hierarchyArr.map((snapshot, index) => {
66+
const selected = index === viewIndex;
67+
return (
68+
<Action
69+
key={`action${index}`}
70+
index={index}
71+
state={snapshot.state}
72+
displayName={snapshot.displayName}
73+
componentName={snapshot.componentName}
74+
selected={selected}
75+
dispatch={dispatch}
76+
sliderIndex={sliderIndex}
77+
handleOnkeyDown={handleOnKeyDown}
78+
viewIndex={viewIndex}
79+
/>
80+
);
81+
});
5782

5883
return (
5984
<div className="action-container">

src/app/containers/HeadContainer.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import SwitchAppDropdown from '../components/SwitchApp';
44
function HeadContainer() {
55
return (
66
<div className="head-container">
7+
<img src ="https://i.imgur.com/19jt84a.png" height= "30px"/>
78
<SwitchAppDropdown />
89
</div>
910
);

src/app/containers/logo4.png

180 KB
Loading

src/app/reducers/mainReducer.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ export default (state, action) => produce(state, draft => {
112112
tabs[currentTab].playing = false;
113113
// gabi :: activate empty mode
114114
tabs[currentTab].mode.empty = true
115-
// gabi :: record snapshot of page inicial state
116-
tabs[currentTab].inicialSnapshot.push(tabs[currentTab].snapshots[0]);
115+
// gabi :: record snapshot of page initial state
116+
tabs[currentTab].initialSnapshot.push(tabs[currentTab].snapshots[0]);
117117
// gabi :: reset snapshots to page last state recorded
118118
tabs[currentTab].snapshots = [ tabs[currentTab].snapshots[tabs[currentTab].snapshots.length - 1] ];
119-
// gabi :: record hierarchy of page inicial state
120-
tabs[currentTab].inicialHierarchy = {...tabs[currentTab].hierarchy};
121-
tabs[currentTab].inicialHierarchy.children = [];
119+
// gabi :: record hierarchy of page initial state
120+
tabs[currentTab].initialHierarchy = {...tabs[currentTab].hierarchy};
121+
tabs[currentTab].initialHierarchy.children = [];
122122
// gabi :: reset hierarchy
123123
tabs[currentTab].hierarchy.children = [];
124124
// gabi :: reset hierarchy to page last state recorded
@@ -222,6 +222,7 @@ export default (state, action) => produce(state, draft => {
222222
draft.currentTab = action.payload.tabId;
223223
break;
224224
}
225+
break;
225226
}
226227
case types.DELETE_TAB: {
227228
delete draft.tabs[action.payload];

src/app/styles/components/d3graph.css

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ body {
1313
fill: #5249f7;
1414
}
1515

16-
.node circle:hover {
17-
fill: #9cf4df;
18-
}
16+
/* .node circle:hover {
17+
fill: #320a5c;
18+
} */
1919

2020
.node text {
2121
font-size: 10px;
2222
font-family: "Overpass Mono", monospace;
2323
}
24+
25+
2426
/* this represents text for leaf nodes aka the ones with no children */
2527
.node--leaf {
2628
fill: #71e9e1;
@@ -34,7 +36,7 @@ body {
3436
/* modifies text of parent nodes (has children) */
3537
.node--internal text {
3638
fill: #fae6e4;
37-
font-size: 11px;
39+
font-size: 10px;
3840
}
3941
.link {
4042
fill: none;

src/extension/background.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ function createTabObj(title) {
1717
title,
1818
// snapshots is an array of ALL state snapshots for the reactime tab working on a specific user application
1919
snapshots: [],
20-
// gabi :: record inicial snapshot to refresh page in case empty function is called
21-
inicialSnapshot: [],
20+
// gabi :: record initial snapshot to refresh page in case empty function is called
21+
initialSnapshot: [],
2222
// gabi and nate :: index here is the tab index that show total amount of state changes
2323
index: 0,
2424
//* this is our pointer so we know what the current state the user is checking (this accounts for time travel aka when user clicks jump on the UI)
@@ -29,8 +29,8 @@ function createTabObj(title) {
2929
currBranch: 0,
3030
//* inserting a new property to build out our hierarchy dataset for d3
3131
hierarchy: null,
32-
// gabi :: record inicial hierarchy to refresh page in case empty function is called
33-
inicialHierarchy: null,
32+
// gabi :: record initial hierarchy to refresh page in case empty function is called
33+
initialHierarchy: null,
3434
mode: {
3535
persist: false,
3636
locked: false,
@@ -140,13 +140,13 @@ chrome.runtime.onConnect.addListener(port => {
140140
case 'emptySnap':
141141
// gabi :: activate empty mode
142142
tabsObj[tabId].mode.empty = true
143-
// gabi :: record snapshot of page inicial state
144-
tabsObj[tabId].inicialSnapshot.push(tabsObj[tabId].snapshots[0]);
143+
// gabi :: record snapshot of page initial state
144+
tabsObj[tabId].initialSnapshot.push(tabsObj[tabId].snapshots[0]);
145145
// gabi :: reset snapshots to page last state recorded
146146
tabsObj[tabId].snapshots = [tabsObj[tabId].snapshots[tabsObj[tabId].snapshots.length - 1] ];
147-
// gabi :: record hierarchy of page inicial state
148-
tabsObj[tabId].inicialHierarchy = {...tabsObj[tabId].hierarchy};
149-
tabsObj[tabId].inicialHierarchy.children = [];
147+
// gabi :: record hierarchy of page initial state
148+
tabsObj[tabId].initialHierarchy = {...tabsObj[tabId].hierarchy};
149+
tabsObj[tabId].initialHierarchy.children = [];
150150
// gabi :: reset hierarchy
151151
tabsObj[tabId].hierarchy.children = [];
152152
// gabi :: reset hierarchy to page last state recorded
@@ -214,17 +214,17 @@ chrome.runtime.onMessage.addListener((request, sender) => {
214214
// dont remove snapshots if persisting
215215
if (!persist) {
216216
if(empty){
217-
// gabi :: reset snapshots to page inicial state recorded when empted
218-
tabsObj[tabId].snapshots = tabsObj[tabId].inicialSnapshot;
219-
// gabi :: reset hierarchy to page inicial state recorded when empted
220-
tabsObj[tabId].hierarchy = tabsObj[tabId].inicialHierarchy
217+
// gabi :: reset snapshots to page initial state recorded when empted
218+
tabsObj[tabId].snapshots = tabsObj[tabId].initialSnapshot;
219+
// gabi :: reset hierarchy to page initial state recorded when empted
220+
tabsObj[tabId].hierarchy = tabsObj[tabId].initialHierarchy;
221221
} else {
222-
// gabi :: reset snapshots to page inicial state
222+
// gabi :: reset snapshots to page initial state
223223
tabsObj[tabId].snapshots.splice(1);
224-
// gabi :: reset hierarchy to page inicial state
224+
// gabi :: reset hierarchy to page initial state
225225
tabsObj[tabId].hierarchy.children = [];
226226
}
227-
// gabi :: reset currLocation to page inicial state
227+
// gabi :: reset currLocation to page initial state
228228
tabsObj[tabId].currLocation = tabsObj[tabId].hierarchy;
229229
// gabi :: reset index
230230
tabsObj[tabId].index = 0;

0 commit comments

Comments
 (0)