Skip to content

Commit aeea7d1

Browse files
authored
Merge pull request #20 from oslabs-beta/amy/axLegend
Amy/ax legend
2 parents fce58c6 + 1ba2d57 commit aeea7d1

File tree

7 files changed

+105
-36
lines changed

7 files changed

+105
-36
lines changed

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

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import React, { useState } 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';
56
import { pointRadial } from 'd3-shape';
67
import { useTooltipInPortal } from '@visx/tooltip';
78
import LinkControls from './axLinkControls';
89
import getLinkComponent from './getAxLinkComponents';
10+
import AxLegend from './axLegend';
11+
import { renderAxLegend } from '../../../slices/AxSlices/axLegendSlice';
12+
import type { RootState } from '../../../store';
913

1014
const theme = {
1115
scheme: 'monokai',
@@ -274,37 +278,41 @@ export default function AxTree(props) {
274278
scroll: true, // when tooltip containers are scrolled, this will correctly update the Tooltip position
275279
});
276280

281+
// ax Legend
282+
const { axLegendButtonClicked } = useSelector((state: RootState) => state.axLegend);
283+
const dispatch = useDispatch();
284+
277285
return totalWidth < 10 ? null : (
278286
<div>
279-
<LinkControls
280-
layout={layout}
281-
orientation={orientation}
282-
linkType={linkType}
283-
stepPercent={stepPercent}
284-
setLayout={setLayout}
285-
setOrientation={setOrientation}
286-
setLinkType={setLinkType}
287-
setStepPercent={setStepPercent}
288-
/>
287+
<div id='axControls'>
288+
<LinkControls
289+
layout={layout}
290+
orientation={orientation}
291+
linkType={linkType}
292+
stepPercent={stepPercent}
293+
setLayout={setLayout}
294+
setOrientation={setOrientation}
295+
setLinkType={setLinkType}
296+
setStepPercent={setStepPercent}
297+
/>
298+
299+
<button id='axLegendButton' onClick={() => dispatch(renderAxLegend())}>
300+
Generate Ax Tree Legend
301+
</button>
302+
</div>
289303

290304
{/* svg references purple background */}
291-
<svg ref={containerRef} width={totalWidth} height={totalHeight + 0}>
305+
<svg ref={containerRef} width={totalWidth + 0.2*totalWidth} height={totalHeight}>
292306
<LinearGradient id='root-gradient' from='#488689' to='#3c6e71' />
293307
<LinearGradient id='parent-gradient' from='#488689' to='#3c6e71' />
294-
<rect
295-
className='componentMapContainer'
296-
width={sizeWidth / aspect}
297-
height={sizeHeight / aspect + 0}
298-
rx={14}
299-
/>
300308
<Group transform={`scale(${aspect})`} top={margin.top} left={margin.left}>
301309
<Tree
302310
root={hierarchy(nodeAxArr[0], (d) => (d.isExpanded ? null : d.children))}
303311
size={[sizeWidth / aspect, sizeHeight / aspect]}
304312
separation={(a, b) => (a.parent === b.parent ? 0.5 : 0.5) / a.depth}
305313
>
306314
{(tree) => (
307-
<Group top={origin.y + 35} left={origin.x + 50 / aspect}>
315+
<Group top={origin.y + 35} left={origin.x + 110}>
308316
{tree.links().map((link, i) => (
309317
<LinkComponent
310318
key={i}
@@ -477,6 +485,14 @@ export default function AxTree(props) {
477485
</Tree>
478486
</Group>
479487
</svg>
488+
489+
{/* ax Legend */}
490+
<div>
491+
{ axLegendButtonClicked ?
492+
<AxLegend /> : ''
493+
}
494+
</div>
495+
480496
</div>
481497
);
482498
}
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)