Skip to content

Commit 737711e

Browse files
authored
Merge branch 'develop' into eva/cleaning
2 parents 581b2de + 5742fb3 commit 737711e

File tree

4 files changed

+40
-203
lines changed

4 files changed

+40
-203
lines changed

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

Lines changed: 15 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -14,135 +14,6 @@ import AxLegend from './axLegend';
1414
import { renderAxLegend } from '../../../slices/AxSlices/axLegendSlice';
1515
import type { RootState } from '../../../store';
1616

17-
//still using below themes?
18-
const theme = {
19-
scheme: 'monokai',
20-
author: 'wimer hazenberg (http://www.monokai.nl)',
21-
base00: '#272822',
22-
base01: '#383830',
23-
base02: '#49483e',
24-
base03: '#75715e',
25-
base04: '#a59f85',
26-
base05: '#f8f8f2',
27-
base06: '#f5f4f1',
28-
base07: '#f9f8f5',
29-
base08: '#f92672',
30-
base09: '#fd971f',
31-
base0A: '#f4bf75',
32-
base0B: '#a6e22e',
33-
base0C: '#a1efe4',
34-
base0D: '#66d9ef',
35-
base0E: '#ae81ff',
36-
base0F: '#cc6633',
37-
};
38-
39-
interface TreeNode {
40-
name?: {
41-
sources?: any[];
42-
type?: string;
43-
value?: string;
44-
};
45-
isExpanded?: boolean;
46-
children?: TreeNode[];
47-
backendDOMNodeId?: number;
48-
childIds?: string[];
49-
ignored?: boolean;
50-
nodeId?: string;
51-
ignoredReasons?: any[];
52-
}
53-
54-
// example data from visx
55-
56-
// pulling name property value to name the node, need to adjust data pull from ax tree to reassign name if the node is ignored
57-
58-
const data: TreeNode = {
59-
name: {
60-
sources: [{ attribute: 'aria-labelledby', type: 'relatedElement' }],
61-
type: 'computedString',
62-
value: 'Reactime MVP',
63-
},
64-
backendDOMNodeId: 1,
65-
childIds: ['46'],
66-
ignored: false,
67-
children: [
68-
{
69-
name: {
70-
sources: [{ attribute: 'aria-labelledby', type: 'relatedElement' }],
71-
type: 'computedString',
72-
value: '',
73-
},
74-
backendDOMNodeId: 7,
75-
childIds: ['47'],
76-
ignored: true,
77-
},
78-
{
79-
name: {
80-
sources: [{ attribute: 'aria-labelledby', type: 'relatedElement' }],
81-
type: 'computedString',
82-
value: 'Tic-Tac-Toe',
83-
},
84-
backendDOMNodeId: 8,
85-
childIds: ['48'],
86-
ignored: false,
87-
},
88-
],
89-
};
90-
91-
const nodeAxArr = [
92-
{
93-
name: {
94-
sources: [{ attribute: 'aria-labelledby', type: 'relatedElement' }],
95-
type: 'computedString',
96-
value: 'Reactime MVP',
97-
},
98-
backendDOMNodeId: 1,
99-
childIds: ['46'],
100-
ignored: false,
101-
children: [
102-
{
103-
name: {
104-
sources: [{ attribute: 'aria-labelledby', type: 'relatedElement' }],
105-
type: 'computedString',
106-
value: '',
107-
},
108-
backendDOMNodeId: 7,
109-
childIds: ['47'],
110-
ignored: true,
111-
},
112-
{
113-
name: {
114-
sources: [{ attribute: 'aria-labelledby', type: 'relatedElement' }],
115-
type: 'computedString',
116-
value: 'Tic-Tac-Toe',
117-
},
118-
backendDOMNodeId: 8,
119-
childIds: ['48'],
120-
ignored: false,
121-
},
122-
],
123-
},
124-
{
125-
name: {
126-
sources: [{ attribute: 'aria-labelledby', type: 'relatedElement' }],
127-
type: 'computedString',
128-
value: '',
129-
},
130-
backendDOMNodeId: 7,
131-
childIds: ['47'],
132-
ignored: true,
133-
},
134-
{
135-
name: {
136-
sources: [{ attribute: 'aria-labelledby', type: 'relatedElement' }],
137-
type: 'computedString',
138-
value: 'Tic-Tac-Toe',
139-
},
140-
backendDOMNodeId: 8,
141-
childIds: ['48'],
142-
ignored: false,
143-
},
144-
];
145-
14617
const defaultMargin = {
14718
top: 30,
14819
left: 30,
@@ -166,8 +37,6 @@ export type LinkTypesProps = {
16637
export default function AxTree(props) {
16738
const { currLocation, axSnapshots, width, height } = props;
16839

169-
170-
17140
let margin = defaultMargin;
17241
let totalWidth = width;
17342
let totalHeight = height;
@@ -243,16 +112,22 @@ export default function AxTree(props) {
243112
// root node of currAxSnapshot
244113
const rootAxNode = JSON.parse(JSON.stringify(currAxSnapshot[0]));
245114

246-
// // array that holds the ax tree as a nested object and the root node initially
115+
// array that holds each ax tree node with children property
247116
const nodeAxArr = [];
248117

118+
// populates ax nodes with children property; visx recognizes 'children' in order to properly render a nested tree
249119
const organizeAxTree = (currNode, currAxSnapshot) => {
120+
// checks if current ax node has children nodes through childId
250121
if (currNode.childIds && currNode.childIds.length > 0) {
122+
// if yes, add children property to current ax node
251123
currNode.children = [];
252124
for (let j = 0; j < currAxSnapshot.length; j++) {
125+
// locate ax node associated with childId
253126
for (const childEle of currNode.childIds) {
254127
if (childEle === currAxSnapshot[j].nodeId) {
128+
// store ax node in children array
255129
currNode.children.push(currAxSnapshot[j]);
130+
// recursively call organizeAxTree with child ax node passed in to check for further nested children nodes
256131
organizeAxTree(currAxSnapshot[j], currAxSnapshot);
257132
}
258133
}
@@ -262,27 +137,26 @@ export default function AxTree(props) {
262137

263138
organizeAxTree(rootAxNode, currAxSnapshot);
264139

265-
// store each individual node, now with children property in nodeAxArr
266-
// need to consider order, iterate through the children property first?
140+
// stores each individual ax node with populated children property in array
267141
const populateNodeAxArr = (currNode) => {
268142
nodeAxArr.splice(0, nodeAxArr.length);
269143
nodeAxArr.push(currNode);
270144
for (let i = 0; i < nodeAxArr.length; i += 1) {
271-
// iterate through the nodeList that contains our snapshot
145+
// iterate through the nodeAxArr that contains the root ax node
272146
const cur = nodeAxArr[i];
273147
if (cur.children && cur.children.length > 0) {
274-
// if the currently itereated snapshot has non-zero children...
148+
// if the current ax node evaluated has non-zero children...
275149
for (const child of cur.children) {
276-
// iterate through each child in the children array
277-
nodeAxArr.push(child); // add the child to the nodeList
150+
// iterate through each child ax node in the children array
151+
nodeAxArr.push(child); // add the child to the nodeAxArr
278152
}
279153
}
280154
}
281155
};
282156

283157
populateNodeAxArr(rootAxNode);
284158

285-
// ax Legend
159+
// Conditionally render ax legend component (RTK)
286160
const { axLegendButtonClicked } = useSelector((state: RootState) => state.axLegend);
287161
const dispatch = useDispatch();
288162

@@ -305,7 +179,6 @@ export default function AxTree(props) {
305179
</button>
306180
</div>
307181

308-
{/* svg references purple background */}
309182
<svg ref={containerRef} width={totalWidth + 0.2*totalWidth} height={totalHeight}>
310183
<LinearGradient id='root-gradient' from='#488689' to='#3c6e71' />
311184
<LinearGradient id='parent-gradient' from='#488689' to='#3c6e71' />
@@ -338,9 +211,8 @@ export default function AxTree(props) {
338211
// code relating to each node in tree
339212
{tree.descendants().map((node, key) => {
340213
const widthFunc = (name): number => {
341-
//returns a number that is related to the length of the name. Used for determining the node width.
214+
// returns a number that is related to the length of the name. Used for determining the node width.
342215
const nodeLength = name.length;
343-
//return nodeLength * 7 + 20; //uncomment this line if we want each node to be directly proportional to the name.length (instead of nodes of similar sizes to snap to the same width)
344216
if (nodeLength <= 5) return nodeLength + 60;
345217
if (nodeLength <= 10) return nodeLength + 130;
346218
return nodeLength + 160;
@@ -524,7 +396,6 @@ export default function AxTree(props) {
524396
fontFamily='Roboto'
525397
textAnchor='middle'
526398
style={{ pointerEvents: 'none' }}
527-
//fill={node.depth === 0 ? '#161521' : node.children ? 'white' : '#161521'}
528399
>
529400
{node.data.name.value}
530401
</text>
@@ -568,6 +439,7 @@ export default function AxTree(props) {
568439
</div>
569440
</TooltipInPortal>
570441
)}
442+
571443
<div>
572444
{ axLegendButtonClicked ?
573445
<AxLegend /> : ''

src/app/components/StateRoute/StateRoute.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const StateRoute = (props: StateRouteProps) => {
4040
const hierarchy = propsHierarchy || tabsHierarchy;
4141
const viewIndex = propsViewIndex || tabsViewIndex;
4242

43+
44+
// lines 45 - 63 contains functionality to disable the accessibility features in Reactime.
4345
const dispatch = useDispatch();
4446
const [showTree, setShowTree] = useState(false);
4547
const [selectedValue, setSelectedValue] = useState('disable');
@@ -123,6 +125,8 @@ const StateRoute = (props: StateRouteProps) => {
123125
<Route
124126
path='/accessibility'
125127
element={
128+
// showTree is initially set to a falsely value, therefore, lines 155 - 189 is executed first. Once showTree is set to truthy by clicking the enable button, lines 129 - 154 is executed
129+
// state is a key component here in order to update the accessibility tree
126130
showTree ? (
127131
<div>
128132
<input
@@ -270,3 +274,4 @@ const StateRoute = (props: StateRouteProps) => {
270274
};
271275

272276
export default StateRoute;
277+

src/app/styles/layout/_stateContainer.scss

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22
font-size: 10px;
33
overflow: auto;
44
background-color: $state-background;
5-
// margin-left: 5px;
65
}
76

87
.toggleAC {
9-
// color: #00dffc;
10-
//color: $blue-brand;
118
background: #ff0001;
129
height: 50%;
1310
text-decoration: none;
@@ -19,16 +16,6 @@
1916
box-shadow: none;
2017
}
2118

22-
// .state-container .navbar {
23-
// //background-color: $state-background;
24-
// //color: #ff0000;
25-
// display: flex;
26-
// flex-direction: row;
27-
// justify-content: flex-start;
28-
// align-items: center;
29-
// height: 30px;
30-
// }
31-
3219
.state-container .main-navbar {
3320
background-color: $state-background;
3421
color: #ff0000;
@@ -59,15 +46,6 @@
5946
height: 35px;
6047
}
6148

62-
// .navbar {
63-
// color: #ff0000;
64-
// // prevent navbar from scrolling with state/tree display
65-
// position: sticky;
66-
// left: 0;
67-
// top: 0;
68-
// @extend %disable-highlight;
69-
// }
70-
7149
.no-data-message {
7250
color: #ff0001;
7351
font: normal 13px $text-font-stack;

0 commit comments

Comments
 (0)