Skip to content

Commit aa812c2

Browse files
more pseudocode added
1 parent c2229c9 commit aa812c2

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

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

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@ export default function ComponentMap({
3838
currentSnapshot, // from 'tabs[currentTab].stateSnapshot object in 'MainContainer'
3939
}: LinkTypesProps): JSX.Element {
4040

41-
const [layout, setLayout] = useState('cartesian');
42-
const [orientation, setOrientation] = useState('vertical');
43-
const [linkType, setLinkType] = useState('diagonal');
44-
const [stepPercent, setStepPercent] = useState(10);
45-
const [selectedNode, setSelectedNode] = useState('root');
46-
const [, dispatch] = useStoreContext();
47-
const toolTipTimeoutID = useRef(null);
41+
const [layout, setLayout] = useState('cartesian'); // We create a local state "layout" and set it to a string 'cartesian'
42+
const [orientation, setOrientation] = useState('vertical'); // We create a local state "orientation" and set it to a string 'vertical'.
43+
const [linkType, setLinkType] = useState('diagonal'); // We create a local state "linkType" and set it to a string 'diagonal'.
44+
const [stepPercent, setStepPercent] = useState(10); // We create a local state "stepPercent" and set it to a number '10'.
45+
const [selectedNode, setSelectedNode] = useState('root'); // We create a local state "selectedNode" and set it to a string 'root'.
46+
const [, dispatch] = useStoreContext(); // we destructure the returned context object from the invocation of the useStoreContext function to get access to our dispatch function
47+
48+
const toolTipTimeoutID = useRef(null); //useRef stores stateful data that’s not needed for rendering.
4849

4950
useEffect(() => {
5051
dispatch(setCurrentTabInApp('map')); // dispatch sent at initial page load allowing changing "immer's" draft.currentTabInApp to 'map' to facilitate render.
@@ -58,24 +59,28 @@ export default function ComponentMap({
5859
let sizeWidth: number;
5960
let sizeHeight: number;
6061

61-
// This sets the starting position for the root node on the maps display.
62-
// the polar layout sets the root node to the relative center of the display box
63-
// based on the size of the browser window.
64-
// the else conditional statements determines the root nodes location either in the left middle
65-
// or top middle of the browser window relative to the size of the browser.
66-
if (layout === 'polar') {
62+
/*
63+
This sets the starting position for the root node on the maps display.
64+
The 'polar layout' sets the root node to the relative center of the display box based on the size of the browser window.
65+
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.
66+
*/
67+
68+
if (layout === 'polar') { // 'polar layout' option
6769
origin = {
6870
x: innerWidth / 2,
6971
y: innerHeight / 2,
7072
};
73+
74+
// set the sizeWidth and sizeHeight
7175
sizeWidth = 2 * Math.PI;
7276
sizeHeight = Math.min(innerWidth, innerHeight) / 2;
73-
} else {
77+
78+
} else { // 'cartesian layout' option
7479
origin = { x: 0, y: 0 };
7580
if (orientation === 'vertical') {
7681
sizeWidth = innerWidth;
7782
sizeHeight = innerHeight;
78-
} else {
83+
} else { // if the orientation isn't vertical, swap the width and the height
7984
sizeWidth = innerHeight;
8085
sizeHeight = innerWidth;
8186
}

src/app/components/Tutorial.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default class Tutorial extends Component<TutorialProps, TutorialState> {
4949
}
5050
if (currentTabInApp === 'performance' && currentStepIndex === 5) {
5151
this.steps.updateStepElement(currentStepIndex);
52-
dispatch(('performance-comparison')); // dispatch sent at initial page load allowing changing "immer's" draft.currentTabInApp to 'performance-comparison.' to facilitate render.
52+
dispatch(setCurrentTabInApp('performance-comparison')); // dispatch sent at initial page load allowing changing "immer's" draft.currentTabInApp to 'performance-comparison.' to facilitate render.
5353
}
5454
if (currentTabInApp === 'performance-comparison' && currentStepIndex === 6) {
5555
dispatch(tutorialSaveSeriesToggle(false));

0 commit comments

Comments
 (0)