Skip to content

Commit 161bd5f

Browse files
Merge branch 'dev' into click-tab/ragad
2 parents 97fd9f1 + 72fa443 commit 161bd5f

25 files changed

+456
-581
lines changed

src/app/App.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import React from 'react';
22
import { MemoryRouter as Router } from 'react-router-dom';
33
import MainContainer from './containers/MainContainer';
4-
import { ThemeProvider } from '@mui/material/styles';
5-
import theme from './styles/theme';
64

75
/*
86
'currentTab' is the current active tab within Google Chrome.
@@ -12,12 +10,10 @@ import theme from './styles/theme';
1210

1311
function App(): JSX.Element {
1412
return (
15-
<ThemeProvider theme={theme}>
16-
<Router>
17-
{/* we wrap our application with the <Router> tag so that all components that are nested will have the react-router context */}
18-
<MainContainer />
19-
</Router>
20-
</ThemeProvider>
13+
<Router>
14+
{/* we wrap our application with the <Router> tag so that all components that are nested will have the react-router context */}
15+
<MainContainer />
16+
</Router>
2117
);
2218
}
2319

src/app/FrontendTypes.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export interface HandleProps {
255255

256256
export interface MainSliderProps {
257257
className: string;
258-
snapshotsLength: number;
258+
snapshots: any[];
259259
}
260260

261261
export interface DefaultMargin {
@@ -303,12 +303,10 @@ export interface StepsObj {
303303
}
304304

305305
export interface LinkControlProps {
306-
layout: string;
307306
orientation: string;
308307
linkType: string;
309308
stepPercent: number;
310309
selectedNode: string;
311-
setLayout: (layout: string) => void;
312310
setOrientation: (orientation: string) => void;
313311
setLinkType: (linkType: string) => void;
314312
setStepPercent: (percent: number) => void;
@@ -339,7 +337,6 @@ export interface Node {
339337
}
340338

341339
export interface LinkComponent {
342-
layout: string;
343340
linkType: string;
344341
orientation: string;
345342
}

src/app/components/Actions/Action.tsx

Lines changed: 30 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,59 @@
1-
/* eslint-disable react/require-default-props */
2-
/* eslint-disable @typescript-eslint/no-explicit-any */
3-
/* eslint-disable react/no-unused-prop-types */
4-
51
import React from 'react';
62
import ReactHover, { Trigger, Hover } from 'react-hover';
73
import { changeView, changeSlider } from '../../slices/mainSlice';
84
import { ActionProps, OptionsCursorTrueWithMargin } from '../../FrontendTypes';
95
import { useDispatch } from 'react-redux';
106

11-
/*
12-
This renders the individual snapshot components on the left side column
13-
*/
14-
15-
/**
16-
* @function Action
17-
* @param selected : The selected action in the array of state changes
18-
* @param displayName : Label showing sequence number of state change, reflects changes in Chart.tsx
19-
* @param componentName : Displays the name of compenent's state being changed
20-
* @param last : The last index in the array
21-
* @param sliderIndex: Index of the slider in the array of state changes
22-
* (clicking the block changes the slider, related to MainSlider.tsx slider)
23-
* @param componentData: Displays react fiber data
24-
* @param viewIndex: Index of the tab in the array when timejump is made
25-
* @method dispatch Executes actions that changes state in reactime
26-
* @method handleOnkeyDown Executes key commands
27-
*
28-
*/
29-
307
const Action = (props: ActionProps): JSX.Element => {
31-
//here we are adding useSelector and useDispatch for RTK state conversion
328
const dispatch = useDispatch();
339

34-
// We destructure the 'props' that were passed into this component
3510
const {
36-
selected, // boolean on whether the current index is the same as the viewIndex in 'ActionContainer'
37-
last, // boolean on (whether the view index is less than 0) AND if (the index is the same as the last snapshot's index value in hierarchyArr) in 'ActionContainer'
38-
index, // from snapshot.index in "ActionContainer's" 'hierarchyArr'
39-
sliderIndex, // from tabs[currentTab] object in 'ActionContainer'
40-
displayName, // from snapshot.displayName in "ActionContainer's" 'hierarchyArr'
41-
componentData, // from snapshot.componentData in "ActionContainer's" 'hierarchyArr'
42-
viewIndex, // from tabs[currentTab] object in 'ActionContainer'
11+
selected,
12+
last,
13+
index,
14+
sliderIndex,
15+
displayName,
16+
componentData,
17+
viewIndex,
4318
isCurrIndex,
44-
handleOnkeyDown, // function that allows arrows keys to jump between snapshots defined in 'ActionContainer.tsx'
19+
handleOnkeyDown,
4520
} = props;
4621

47-
/**
48-
* @function cleanTime: Displays render times for state changes
49-
* @returns render display time in seconds in milliseconds
50-
*/
51-
5222
const cleanTime = (): string => {
5323
if (!componentData || !componentData.actualDuration) {
54-
// if there is no 'componentData' or 'componentData.actualDuration'
5524
return 'NO TIME';
5625
}
5726

58-
let seconds: number | string; // seconds is undefined but can take a number or a string
59-
let milliseconds: any = componentData.actualDuration; // milliseconds is of any type and taken from the 'componentData.actualDuration'
27+
let seconds: number | string;
28+
let milliseconds: any = componentData.actualDuration;
6029

6130
if (Math.floor(componentData.actualDuration) > 60) {
62-
// if the milliseconds is greater than 60
63-
seconds = Math.floor(componentData.actualDuration / 60); // we divide our milliseconds by 60 to determine our seconds
64-
seconds = JSON.stringify(seconds); // and we convert our seconds into a string
31+
seconds = Math.floor(componentData.actualDuration / 60);
32+
seconds = JSON.stringify(seconds);
6533

6634
if (seconds.length < 2) {
67-
// if the seconds string is only a single digit
68-
seconds = '0'.concat(seconds); // we can add a 0 in front of it so that if 'seconds = "1"' it will come out as 'seconds = "01"'
35+
seconds = '0'.concat(seconds);
6936
}
70-
milliseconds = Math.floor(componentData.actualDuration % 60); // Our true milliseconds then becomes the remainder of dividing our initial milliseconds by 60
37+
milliseconds = Math.floor(componentData.actualDuration % 60);
7138
} else {
72-
seconds = '00'; // if we haven't even reached one second yet, our seconds are 00
39+
seconds = '00';
7340
}
7441

75-
milliseconds = Number.parseFloat(milliseconds as string).toFixed(2); // we convert our milliseconds string into a floating point number that has up to two decimal places.
76-
const arrayMilliseconds: [string, number] = milliseconds.split('.'); // we split our milliseconds using the decimal and come out with an array of two numbers
42+
milliseconds = Number.parseFloat(milliseconds as string).toFixed(2);
43+
const arrayMilliseconds: [string, number] = milliseconds.split('.');
7744

7845
if (arrayMilliseconds[0].length < 2) {
79-
// if our millisecond string only has one digit
80-
arrayMilliseconds[0] = '0'.concat(arrayMilliseconds[0]); // we add a 0 in front of it so that in the a sample number of '1' becomes '01'
46+
arrayMilliseconds[0] = '0'.concat(arrayMilliseconds[0]);
8147
}
8248

8349
if (index === 0) {
84-
// if this is the initial snapshot
85-
return `${seconds}:${arrayMilliseconds[0]}.${arrayMilliseconds[1]}`; // we give it a timestamp
50+
return `${seconds}:${arrayMilliseconds[0]}.${arrayMilliseconds[1]}`;
8651
}
87-
return `+${seconds}:${arrayMilliseconds[0]}.${arrayMilliseconds[1]}`; // if these are succeeding snapshots, we add a '+' to the timestamp
52+
return `+${seconds}:${arrayMilliseconds[0]}.${arrayMilliseconds[1]}`;
8853
};
8954

90-
const displayTime: string = cleanTime(); // we run cleanTime on the creation of this component so that we can get the timestamp
55+
const displayTime: string = cleanTime();
9156

92-
// creates an options object that 'ReactHover' component will use to modify it's behaviour
9357
const optionsCursorTrueWithMargin: OptionsCursorTrueWithMargin = {
9458
followCursor: true,
9559
shiftX: 20,
@@ -123,9 +87,15 @@ const Action = (props: ActionProps): JSX.Element => {
12387
placeholder={`Snapshot: ${displayName}`}
12488
/>
12589
</div>
126-
<button className='time-button' type='button'>
127-
{displayTime}
128-
</button>
90+
{isCurrIndex ? (
91+
<button className='current-snap' type='button'>
92+
{`Snapshot: ${displayName}`}
93+
</button>
94+
) : (
95+
<button className='time-button' type='button'>
96+
{displayTime}
97+
</button>
98+
)}
12999
{isCurrIndex ? (
130100
<button className='current-location' type='button'>
131101
Current

src/app/components/Actions/RouteDescription.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React from 'react';
2+
import Slider from 'rc-slider';
3+
import VerticalSlider from '../TimeTravel/VerticalSlider';
24

35
/*
46
Render's the red route description on app's left sided column between the clear button and the list of state snapshots. The route description is derived from the first state snapshot.
@@ -12,10 +14,19 @@ const RouteDescription = (props: RouteProps): JSX.Element => {
1214
const { actions } = props;
1315

1416
const url: URL = new URL(actions[0].props.routePath); // Use new URL to use the url.pathname method.
17+
1518
return (
16-
<div className='routedescription'>
17-
<h3 className='route'>Route: {url.pathname}</h3>
18-
{actions}
19+
<div className='route-container'>
20+
<div className='route-header'>Route: {url.pathname}</div>
21+
<div className='route-content' style={{ height: `${actions.length * 40.5}px` }}>
22+
<div>
23+
<VerticalSlider className='main-slider' snapshots={actions} />
24+
</div>
25+
<div className='actions-container'>
26+
{/* actual snapshots per route */}
27+
{actions}
28+
</div>
29+
</div>
1930
</div>
2031
);
2132
};

src/app/components/StateRoute/AxMap/Ax.tsx

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function AxTree(props) {
5252
showTooltip, // function to set tooltip state
5353
hideTooltip, // function to close a tooltip
5454
} = useTooltip(); // returns an object with several properties that you can use to manage the tooltip state of your component
55-
55+
5656
const {
5757
containerRef, // Access to the container's bounding box. This will be empty on first render.
5858
TooltipInPortal, // TooltipWithBounds in a Portal, outside of your component DOM tree
@@ -75,7 +75,6 @@ export default function AxTree(props) {
7575
pointerEvents: 'all !important',
7676
};
7777

78-
const [layout, setLayout] = useState('cartesian');
7978
const [orientation, setOrientation] = useState('horizontal');
8079
const [linkType, setLinkType] = useState('diagonal');
8180
const [stepPercent, setStepPercent] = useState(0.5);
@@ -87,32 +86,23 @@ export default function AxTree(props) {
8786
let sizeWidth: number;
8887
let sizeHeight: number;
8988

90-
if (layout === 'polar') {
91-
origin = {
92-
x: innerWidth / 2,
93-
y: innerHeight / 2,
94-
};
95-
sizeWidth = 2 * Math.PI;
96-
sizeHeight = Math.min(innerWidth, innerHeight) / 2;
89+
origin = { x: 0, y: 0 };
90+
if (orientation === 'vertical') {
91+
sizeWidth = innerWidth;
92+
sizeHeight = innerHeight;
9793
} else {
98-
origin = { x: 0, y: 0 };
99-
if (orientation === 'vertical') {
100-
sizeWidth = innerWidth;
101-
sizeHeight = innerHeight;
102-
} else {
103-
sizeWidth = innerHeight;
104-
sizeHeight = innerWidth;
105-
}
94+
sizeWidth = innerHeight;
95+
sizeHeight = innerWidth;
10696
}
10797

108-
const LinkComponent = getLinkComponent({ layout, linkType, orientation });
98+
const LinkComponent = getLinkComponent({ linkType, orientation });
10999

110100
const currAxSnapshot = JSON.parse(JSON.stringify(axSnapshots[currLocation.index]));
111101

112102
// root node of currAxSnapshot
113103
const rootAxNode = JSON.parse(JSON.stringify(currAxSnapshot[0]));
114104

115-
// array that holds each ax tree node with children property
105+
// array that holds each ax tree node with children property
116106
const nodeAxArr = [];
117107

118108
// populates ax nodes with children property; visx recognizes 'children' in order to properly render a nested tree
@@ -164,11 +154,9 @@ export default function AxTree(props) {
164154
<div>
165155
<div id='axControls'>
166156
<LinkControls
167-
layout={layout}
168157
orientation={orientation}
169158
linkType={linkType}
170159
stepPercent={stepPercent}
171-
setLayout={setLayout}
172160
setOrientation={setOrientation}
173161
setLinkType={setLinkType}
174162
setStepPercent={setStepPercent}
@@ -179,17 +167,18 @@ export default function AxTree(props) {
179167
</button>
180168
</div>
181169

182-
<svg ref={containerRef} width={totalWidth + 0.2*totalWidth} height={totalHeight}>
170+
<svg ref={containerRef} width={totalWidth + 0.2 * totalWidth} height={totalHeight}>
183171
<LinearGradient id='root-gradient' from='#488689' to='#3c6e71' />
184172
<LinearGradient id='parent-gradient' from='#488689' to='#3c6e71' />
185173
<rect
186174
className='componentMapContainer'
187175
width={sizeWidth / aspect}
188176
height={sizeHeight / aspect + 0}
189177
rx={14}
190-
onClick={() => {
178+
onClick={() => {
191179
hideTooltip();
192-
}}/>
180+
}}
181+
/>
193182
<Group transform={`scale(${aspect})`} top={margin.top} left={margin.left}>
194183
<Tree
195184
root={hierarchy(nodeAxArr[0], (d) => (d.isExpanded ? null : d.children))}
@@ -223,11 +212,7 @@ export default function AxTree(props) {
223212
let top: number;
224213
let left: number;
225214

226-
if (layout === 'polar') {
227-
const [radialX, radialY] = pointRadial(node.x, node.y);
228-
top = radialY;
229-
left = radialX;
230-
} else if (orientation === 'vertical') {
215+
if (orientation === 'vertical') {
231216
top = node.y;
232217
left = node.x;
233218
} else {
@@ -430,8 +415,8 @@ export default function AxTree(props) {
430415
<div>
431416
<div>
432417
{/*tooltipData['name'].value cannot be referred to using dot notation so using brackets here overrides typescript's strict data typing which was interfering with accessiccing this property */}
433-
<strong>{JSON.stringify(tooltipData['name'].value)}</strong>
434-
</div>
418+
<strong>{JSON.stringify(tooltipData['name'].value)}</strong>
419+
</div>
435420
<div>
436421
{/* Ax Node Info below names the tooltip title because of how its passed to the ToolTipDataDisplay container*/}
437422
<ToolTipDataDisplay containerName='Ax Node Info' dataObj={tooltipData} />
@@ -440,12 +425,7 @@ export default function AxTree(props) {
440425
</TooltipInPortal>
441426
)}
442427

443-
<div>
444-
{ axLegendButtonClicked ?
445-
<AxLegend /> : ''
446-
}
447-
</div>
448-
428+
<div>{axLegendButtonClicked ? <AxLegend /> : ''}</div>
449429
</div>
450430
);
451431
}

0 commit comments

Comments
 (0)