Skip to content

Commit 54c07ce

Browse files
committed
formatted all files with prettier
1 parent e9bbeae commit 54c07ce

36 files changed

+487
-419
lines changed

src/app/components/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function App(): JSX.Element {
1515
<ThemeProvider theme={theme}>
1616
<Router>
1717
{/* we wrap our application with the <Router> tag so that all components that are nested will have the react-router context */}
18-
<MainContainer />
18+
<MainContainer />
1919
</Router>
2020
</ThemeProvider>
2121
);

src/app/components/DiffRoute.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { DiffRouteProps } from '../FrontendTypes';
1010
// 'DiffRoute' only passed in prop is 'snapshot' from 'tabs[currentTab]' object in 'MainContainer'
1111
const DiffRoute = (props: DiffRouteProps): JSX.Element => (
1212
<Router>
13-
<div className='navbar'>
13+
<div className='navbar'>
1414
<NavLink className='router-link' activeClassName='is-active' exact to='/'>
1515
Tree
1616
</NavLink>

src/app/components/Dropdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import Select from 'react-select';
3-
import { DropdownProps } from '../FrontendTypes'
3+
import { DropdownProps } from '../FrontendTypes';
44

55
/*
66
Allows the user to change the speed of the time-travel based on the selected dropdown value

src/app/components/ErrorMsg.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,20 @@ function parseError(loadingArray: [], status: Record<string, unknown>): string {
2727
}
2828

2929
function ErrorMsg({ loadingArray, status, launchContent }): JSX.Element {
30-
switch (parseError(loadingArray, status)) { // parseError returns a string based on the loadingArray and status. The returned string is matched to a case so that an appropriate error message will be displayed to the user
30+
switch (
31+
parseError(loadingArray, status) // parseError returns a string based on the loadingArray and status. The returned string is matched to a case so that an appropriate error message will be displayed to the user
32+
) {
3133
case 'Content Script Error':
3234
return (
3335
<div>
3436
Could not connect to the Target App. Try closing Reactime and reloading the page.
3537
<br />
3638
<br />
37-
If you encounter this error on the initial launch of Reactime, refresh the webpage you are developing.
39+
If you encounter this error on the initial launch of Reactime, refresh the webpage you are
40+
developing.
3841
<br />
39-
If Reactime is running as an iframe in your developer tools, right click on the Reactime application and click 'Reload Frame'
42+
If Reactime is running as an iframe in your developer tools, right click on the Reactime
43+
application and click 'Reload Frame'
4044
<br />
4145
<br />
4246
NOTE: By default Reactime only launches the content script on URLS starting with
@@ -57,9 +61,11 @@ function ErrorMsg({ loadingArray, status, launchContent }): JSX.Element {
5761
React Dev Tools is not installed!
5862
<br />
5963
<br />
60-
If you encounter this error on the initial launch of Reactime, refresh the webpage you are developing.
64+
If you encounter this error on the initial launch of Reactime, refresh the webpage you are
65+
developing.
6166
<br />
62-
If Reactime is running as an iframe in your developer tools, right click on the Reactime application and click 'Reload Frame'
67+
If Reactime is running as an iframe in your developer tools, right click on the Reactime
68+
application and click 'Reload Frame'
6369
<br />
6470
<br />
6571
<a

src/app/components/Loader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ This file is what decides what icon (loading, checkmark, exclamation point) is d
1515

1616
const handleResult = (result: boolean): JSX.Element =>
1717
result ? (
18-
<CheckCircleOutlineIcon className='check'/> // if result boolean is true, we display a checkmark icon
18+
<CheckCircleOutlineIcon className='check' /> // if result boolean is true, we display a checkmark icon
1919
) : (
20-
<ErrorOutlineIcon className='fail'/> // if the result boolean is false, we display a fail icon
20+
<ErrorOutlineIcon className='fail' /> // if the result boolean is false, we display a fail icon
2121
);
2222

2323
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types

src/app/components/RouteDescription.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type RouteProps = {
1010

1111
const RouteDescription = (props: RouteProps): JSX.Element => {
1212
const { actions } = props;
13-
13+
1414
const url: URL = new URL(actions[0].props.routePath); // Use new URL to use the url.pathname method.
1515
return (
1616
<div className='routedescription'>

src/app/components/StateRoute/ComponentMap/ComponentMap.tsx

Lines changed: 56 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import getLinkComponent from './getLinkComponent';
2020
import ToolTipDataDisplay from './ToolTipDataDisplay';
2121
import { toggleExpanded, setCurrentTabInApp } from '../../../slices/mainSlice';
2222
import { useDispatch } from 'react-redux';
23-
import { LinkTypesProps, DefaultMargin, ToolTipStyles } from '../../../FrontendTypes'
23+
import { LinkTypesProps, DefaultMargin, ToolTipStyles } from '../../../FrontendTypes';
2424

2525
const defaultMargin: DefaultMargin = {
2626
top: 30,
@@ -37,10 +37,10 @@ export default function ComponentMap({
3737
currentSnapshot, // from 'tabs[currentTab].stateSnapshot object in 'MainContainer'
3838
}: LinkTypesProps): JSX.Element {
3939
const [layout, setLayout] = useState('cartesian'); // We create a local state "layout" and set it to a string 'cartesian'
40-
const [orientation, setOrientation] = useState('vertical'); // We create a local state "orientation" and set it to a string 'vertical'.
41-
const [linkType, setLinkType] = useState('diagonal'); // We create a local state "linkType" and set it to a string 'diagonal'.
40+
const [orientation, setOrientation] = useState('vertical'); // We create a local state "orientation" and set it to a string 'vertical'.
41+
const [linkType, setLinkType] = useState('diagonal'); // We create a local state "linkType" and set it to a string 'diagonal'.
4242
const [stepPercent, setStepPercent] = useState(0.5); // We create a local state "stepPercent" and set it to a number '0.5'. This will be used to scale the Map component's link: Step to 50%
43-
const [selectedNode, setSelectedNode] = useState('root'); // We create a local state "selectedNode" and set it to a string 'root'.
43+
const [selectedNode, setSelectedNode] = useState('root'); // We create a local state "selectedNode" and set it to a string 'root'.
4444
const dispatch = useDispatch();
4545

4646
const toolTipTimeoutID = useRef(null); //useRef stores stateful data that’s not needed for rendering.
@@ -63,7 +63,8 @@ export default function ComponentMap({
6363
The 'cartesian layout' (else conditional) sets the root nodes location either in the left middle *or top middle of the browser window relative to the size of the browser.
6464
*/
6565

66-
if (layout === 'polar') { // 'polar layout' option
66+
if (layout === 'polar') {
67+
// 'polar layout' option
6768
origin = {
6869
x: innerWidth / 2,
6970
y: innerHeight / 2,
@@ -72,31 +73,33 @@ export default function ComponentMap({
7273
// set the sizeWidth and sizeHeight
7374
sizeWidth = 2 * Math.PI;
7475
sizeHeight = Math.min(innerWidth, innerHeight) / 2;
75-
76-
} else { // 'cartesian layout' option
76+
} else {
77+
// 'cartesian layout' option
7778
origin = { x: 0, y: 0 };
7879
if (orientation === 'vertical') {
7980
sizeWidth = innerWidth;
8081
sizeHeight = innerHeight;
81-
} else { // if the orientation isn't vertical, swap the width and the height
82+
} else {
83+
// if the orientation isn't vertical, swap the width and the height
8284
sizeWidth = innerHeight;
8385
sizeHeight = innerWidth;
8486
}
8587
}
8688

87-
const {
89+
const {
8890
tooltipData, // value/data that tooltip may need to render
8991
tooltipLeft, // number used for tooltip positioning
9092
tooltipTop, // number used for tooltip positioning
9193
tooltipOpen, // boolean whether the tooltip state is open or closed
9294
showTooltip, // function to set tooltip state
93-
hideTooltip // function to close a tooltip
95+
hideTooltip, // function to close a tooltip
9496
} = useTooltip(); // returns an object with several properties that you can use to manage the tooltip state of your component
9597

9698
const {
97-
containerRef, // Access to the container's bounding box. This will be empty on first render.
98-
TooltipInPortal // TooltipWithBounds in a Portal, outside of your component DOM tree
99-
} = useTooltipInPortal({ // Visx hook
99+
containerRef, // Access to the container's bounding box. This will be empty on first render.
100+
TooltipInPortal, // TooltipWithBounds in a Portal, outside of your component DOM tree
101+
} = useTooltipInPortal({
102+
// Visx hook
100103
detectBounds: true, // use TooltipWithBounds
101104
scroll: true, // when tooltip containers are scrolled, this will correctly update the Tooltip position
102105
});
@@ -130,13 +133,17 @@ export default function ComponentMap({
130133

131134
const nodeList: [] = []; // create a nodeList array to store our nodes as a flat array
132135

133-
const collectNodes: void = (node) => { // function that takes in a node (snapshot) as it's argument and modifies 'nodeList' so that the node and it's children are all within the flattened 'nodeList'.
136+
const collectNodes: void = (node) => {
137+
// function that takes in a node (snapshot) as it's argument and modifies 'nodeList' so that the node and it's children are all within the flattened 'nodeList'.
134138
nodeList.splice(0, nodeList.length); // deletes all the nodes in nodelist
135139
nodeList.push(node); // pushes the snapshot into nodeList
136-
for (let i = 0; i < nodeList.length; i += 1) { // iterate through the nodeList that contains our snapshot
140+
for (let i = 0; i < nodeList.length; i += 1) {
141+
// iterate through the nodeList that contains our snapshot
137142
const cur = nodeList[i];
138-
if (cur.children && cur.children.length > 0) { // if the currently itereated snapshot has non-zero children...
139-
for (const child of cur.children) { // iterate through each child in the children array
143+
if (cur.children && cur.children.length > 0) {
144+
// if the currently itereated snapshot has non-zero children...
145+
for (const child of cur.children) {
146+
// iterate through each child in the children array
140147
nodeList.push(child); // add the child to the nodeList
141148
}
142149
}
@@ -149,7 +156,8 @@ export default function ComponentMap({
149156
let startNode = null;
150157
let rootNode;
151158

152-
const findSelectedNode = () => { // iterates through each node of nodeList and sets the rootNode and startNode to a node with the name root
159+
const findSelectedNode = () => {
160+
// iterates through each node of nodeList and sets the rootNode and startNode to a node with the name root
153161
for (const node of nodeList) {
154162
if (node.name === 'root') rootNode = node;
155163
if (node.name === selectedNode) startNode = node; // selectedNode label initialized as 'root'
@@ -160,16 +168,20 @@ export default function ComponentMap({
160168
findSelectedNode(); // locates the rootNode... do we really need this? This function is only used once... it's here.
161169

162170
// controls for the map
163-
const LinkComponent: React.ComponentType<unknown> = getLinkComponent({ layout, linkType, orientation });
171+
const LinkComponent: React.ComponentType<unknown> = getLinkComponent({
172+
layout,
173+
linkType,
174+
orientation,
175+
});
164176
return totalWidth < 10 ? null : (
165177
<div>
166178
<LinkControls
167-
layout={layout}
168-
orientation={orientation}
169-
linkType={linkType}
170-
stepPercent={stepPercent}
179+
layout={layout}
180+
orientation={orientation}
181+
linkType={linkType}
182+
stepPercent={stepPercent}
171183
snapShots={currentSnapshot}
172-
selectedNode={selectedNode}
184+
selectedNode={selectedNode}
173185
setLayout={setLayout}
174186
setOrientation={setOrientation}
175187
setLinkType={setLinkType}
@@ -208,28 +220,26 @@ export default function ComponentMap({
208220
))}
209221

210222
{tree.descendants().map((node, key) => {
211-
const widthFunc:number = (name) => { // function that takes in a node's name and returns a number that is related to the length of the name. Used for determining the node width.
223+
const widthFunc: number = (name) => {
224+
// function that takes in a node's name and returns a number that is related to the length of the name. Used for determining the node width.
212225
const nodeLength = name.length;
213226
if (nodeLength <= 5) return nodeLength + 80; // returns a number between 80-85
214227
if (nodeLength <= 10) return nodeLength + 120; // returns a number between 125-130
215-
return nodeLength + 140; // returns a number greater than 150
228+
return nodeLength + 140; // returns a number greater than 150
216229
};
217230

218-
const width:number = widthFunc(node.data.name); // the width is determined by the length of the node.name
219-
const height:number = 25;
231+
const width: number = widthFunc(node.data.name); // the width is determined by the length of the node.name
232+
const height: number = 25;
220233
let top: number;
221234
let left: number;
222235

223-
224236
if (layout === 'polar') {
225237
const [radialX, radialY] = pointRadial(node.x, node.y);
226238
top = radialY;
227239
left = radialX;
228-
229240
} else if (orientation === 'vertical') {
230241
top = node.y;
231242
left = node.x;
232-
233243
} else {
234244
top = node.x;
235245
left = node.y;
@@ -284,15 +294,14 @@ export default function ComponentMap({
284294
dispatch(toggleExpanded(node.data));
285295
hideTooltip();
286296
}}
287-
288297
// Mouse Enter Rect (Component Node) -----------------------------------------------------------------------
289298
/** This onMouseEnter event fires when the mouse first moves/hovers over a component node.
290-
* The supplied event listener callback produces a Tooltip element for the current node. */
291-
299+
* The supplied event listener callback produces a Tooltip element for the current node. */
300+
292301
onMouseEnter={(event) => {
293302
/** This 'if' statement block checks to see if you've just left another component node
294-
* by seeing if there's a current setTimeout waiting to close that component node's
295-
* tooltip (see onMouseLeave immediately below). If so it clears the tooltip generated
303+
* by seeing if there's a current setTimeout waiting to close that component node's
304+
* tooltip (see onMouseLeave immediately below). If so it clears the tooltip generated
296305
* from that component node so a new tooltip for the node you've just entered can render. */
297306
if (toolTipTimeoutID.current !== null) {
298307
clearTimeout(toolTipTimeoutID.current);
@@ -303,13 +312,12 @@ export default function ComponentMap({
303312
//This generates a tooltip for the component node the mouse has entered.
304313
handleMouseAndClickOver(event);
305314
}}
306-
307315
// Mouse Leave Rect (Component Node) --------------------------------------------------------------------------
308316
/** This onMouseLeave event fires when the mouse leaves a component node.
309-
* The supplied event listener callback generates a setTimeout call which gives the
310-
* mouse a certain amount of time between leaving the current component node and
317+
* The supplied event listener callback generates a setTimeout call which gives the
318+
* mouse a certain amount of time between leaving the current component node and
311319
* closing the tooltip for that node.
312-
* If the mouse enters the tooltip before the timeout delay has passed, the
320+
* If the mouse enters the tooltip before the timeout delay has passed, the
313321
* setTimeout event will be canceled. */
314322
onMouseLeave={() => {
315323
// Store setTimeout ID so timeout can be cleared if necessary
@@ -348,15 +356,13 @@ export default function ComponentMap({
348356
top={tooltipTop}
349357
left={tooltipLeft}
350358
style={tooltipStyles}
351-
352359
//------------- Mouse Over TooltipInPortal--------------------------------------------------------------------
353360
/** After the mouse enters the tooltip, it's able to persist by clearing the setTimeout
354-
* that would've unmounted it */
361+
* that would've unmounted it */
355362
onMouseEnter={() => {
356363
clearTimeout(toolTipTimeoutID.current);
357364
toolTipTimeoutID.current = null;
358365
}}
359-
360366
//------------- Mouse Leave TooltipInPortal -----------------------------------------------------------------
361367
/** When the mouse leaves the tooltip, the tooltip unmounts */
362368
onMouseLeave={() => {
@@ -371,17 +377,16 @@ export default function ComponentMap({
371377
Key: {tooltipData.componentData.key !== null ? tooltipData.componentData.key : 'null'}
372378
</div>
373379
<div> Render time: {formatRenderTime(tooltipData.componentData.actualDuration)} </div>
374-
380+
375381
<div>
376-
<ToolTipDataDisplay
377-
containerName='Props'
378-
dataObj={tooltipData.componentData.props}
379-
/>
382+
<ToolTipDataDisplay containerName='Props' dataObj={tooltipData.componentData.props} />
380383
<ToolTipDataDisplay
381384
containerName='State'
382-
dataObj={tooltipData.componentData.hooksIndex
383-
? tooltipData.componentData.hooksState
384-
: tooltipData.componentData.state}
385+
dataObj={
386+
tooltipData.componentData.hooksIndex
387+
? tooltipData.componentData.hooksState
388+
: tooltipData.componentData.state
389+
}
385390
/>
386391
</div>
387392
</div>

0 commit comments

Comments
 (0)