Skip to content

Commit 7dc27a9

Browse files
committed
Merge branch 'develop' into eva/debugging
2 parents 4af16ca + aeea7d1 commit 7dc27a9

File tree

7 files changed

+113
-30
lines changed

7 files changed

+113
-30
lines changed

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

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useState, useRef } from 'react';
2+
import { useDispatch, useSelector } from 'react-redux';
23
import { Group } from '@visx/group';
34
import { hierarchy, Tree } from '@visx/hierarchy';
45
import { LinearGradient } from '@visx/gradient';
@@ -9,6 +10,9 @@ import { useTooltip, useTooltipInPortal, defaultStyles } from '@visx/tooltip';
910
import ToolTipDataDisplay from './ToolTipDataDisplay';
1011
import { ToolTipStyles } from '../../../FrontendTypes';
1112
import { localPoint } from '@visx/event';
13+
import AxLegend from './axLegend';
14+
import { renderAxLegend } from '../../../slices/AxSlices/axLegendSlice';
15+
import type { RootState } from '../../../store';
1216

1317
//still using below themes?
1418
const theme = {
@@ -314,21 +318,39 @@ export default function AxTree(props) {
314318
populateNodeAxArr(rootAxNode);
315319
console.log('nodeAxArr: ', nodeAxArr);
316320

321+
const {
322+
containerRef // Access to the container's bounding box. This will be empty on first render.
323+
} = useTooltipInPortal({
324+
// Visx hook
325+
detectBounds: true, // use TooltipWithBounds
326+
scroll: true, // when tooltip containers are scrolled, this will correctly update the Tooltip position
327+
});
328+
329+
// ax Legend
330+
const { axLegendButtonClicked } = useSelector((state: RootState) => state.axLegend);
331+
const dispatch = useDispatch();
332+
317333
return totalWidth < 10 ? null : (
318334
<div>
319-
<LinkControls
320-
layout={layout}
321-
orientation={orientation}
322-
linkType={linkType}
323-
stepPercent={stepPercent}
324-
setLayout={setLayout}
325-
setOrientation={setOrientation}
326-
setLinkType={setLinkType}
327-
setStepPercent={setStepPercent}
328-
/>
335+
<div id='axControls'>
336+
<LinkControls
337+
layout={layout}
338+
orientation={orientation}
339+
linkType={linkType}
340+
stepPercent={stepPercent}
341+
setLayout={setLayout}
342+
setOrientation={setOrientation}
343+
setLinkType={setLinkType}
344+
setStepPercent={setStepPercent}
345+
/>
346+
347+
<button id='axLegendButton' onClick={() => dispatch(renderAxLegend())}>
348+
Generate Ax Tree Legend
349+
</button>
350+
</div>
329351

330352
{/* svg references purple background */}
331-
<svg ref={containerRef} width={totalWidth} height={totalHeight + 0}>
353+
<svg ref={containerRef} width={totalWidth + 0.2*totalWidth} height={totalHeight}>
332354
<LinearGradient id='root-gradient' from='#488689' to='#3c6e71' />
333355
<LinearGradient id='parent-gradient' from='#488689' to='#3c6e71' />
334356
<rect
@@ -346,7 +368,7 @@ export default function AxTree(props) {
346368
separation={(a, b) => (a.parent === b.parent ? 0.5 : 0.5) / a.depth}
347369
>
348370
{(tree) => (
349-
<Group top={origin.y + 35} left={origin.x + 50 / aspect}>
371+
<Group top={origin.y + 35} left={origin.x + 110}>
350372
{tree.links().map((link, i) => (
351373
<LinkComponent
352374
key={i}
@@ -598,6 +620,14 @@ export default function AxTree(props) {
598620
</div>
599621
</TooltipInPortal>
600622
)}
623+
624+
{/* ax Legend */}
625+
<div>
626+
{ axLegendButtonClicked ?
627+
<AxLegend /> : ''
628+
}
629+
</div>
630+
601631
</div>
602632
);
603633
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
3+
const AxLegend = () => {
4+
return (
5+
<div style={{borderStyle: 'solid'}}>
6+
Nodes from the accessibility tree have either a role <strong>role</strong> or <strong>internalRole</strong>
7+
<ul>
8+
<li>
9+
<i><b>Role</b></i> refers to <strong> ARIA </strong> roles, which indicate the purpose of the element to assistive technologies, like screen readers.
10+
All of the nodes rendered in this tree have a role of 'role'
11+
</li>
12+
<li>
13+
<i><b>internalRole</b></i> refers to browser-specific roles <strong> Chrome </strong> for its own accessibility processing
14+
</li>
15+
</ul>
16+
17+
<p> Each node is given a property labeled <strong>ignored</strong>. </p>
18+
<p> Nodes read by the screen reader have their ignored property evaluate to <strong>false</strong>.
19+
Nodes not read by the screen reader evaluate to <strong>true</strong>.</p>
20+
<p> Nodes labeled <strong>"visible node with no name"</strong> have the ignored property set to false, but are not given a name</p>
21+
</div>
22+
);
23+
}
24+
25+
export default AxLegend;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { createSlice } from '@reduxjs/toolkit';
2+
3+
export const axLegendSlice = createSlice({
4+
name: 'axLegend',
5+
initialState: {
6+
axLegendButtonClicked: false,
7+
},
8+
reducers: {
9+
renderAxLegend: (state) => {
10+
if (!state.axLegendButtonClicked) state.axLegendButtonClicked = true;
11+
else state.axLegendButtonClicked = false;
12+
}
13+
}
14+
})
15+
16+
export const { renderAxLegend } = axLegendSlice.actions;
17+
18+
export default axLegendSlice.reducer;

src/app/store.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
//Import store from redux tool kit
22
import { configureStore } from '@reduxjs/toolkit';
33
import { mainSlice } from './slices/mainSlice';
4+
import { axLegendSlice } from './slices/AxSlices/axLegendSlice';
45

56
//Export Store
67
export const store = configureStore({
78
reducer: {
89
main: mainSlice.reducer,
10+
axLegend: axLegendSlice.reducer,
911
},
1012
middleware: (getDefaultMiddleware) => getDefaultMiddleware({ serializableCheck: false }),
1113
});
14+
15+
export type RootState = ReturnType<typeof store.getState>

src/app/styles/components/_ax.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Ax.tsx
2+
#axControls {
3+
display: inline-flex;
4+
position: sticky;
5+
left: 0;
6+
}

src/app/styles/layout/_stateContainer.scss

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@
1919
box-shadow: none;
2020
}
2121

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-
position: static;
31-
}
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+
// }
3231

3332
.state-container .main-navbar {
3433
background-color: $state-background;
@@ -60,13 +59,14 @@
6059
height: 35px;
6160
}
6261

63-
.navbar {
64-
color: #ff0000;
65-
// prevent navbar from scrolling with state/tree display
66-
left: 0px;
67-
z-index: 1;
68-
@extend %disable-highlight;
69-
}
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+
// }
7070

7171
.no-data-message {
7272
color: #ff0001;

src/app/styles/main.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
// 5. Components
4444
@import 'components/buttons', 'components/actionComponent',
4545
'components/jsonTree', 'components/renderingFrequency',
46-
'components/performanceVisx', 'components/componentMap';
46+
'components/performanceVisx', 'components/componentMap', 'components/ax';
4747

4848
// slider component
4949
@import './components/rc-slider', './components/sliderHandle';

0 commit comments

Comments
 (0)