Skip to content

Commit 0e8bd84

Browse files
authored
Merge pull request #9 from oslabs-beta/eva/axComponents
with new reactime ax tree
2 parents 300ad6d + 5c2c92f commit 0e8bd84

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

src/app/components/StateRoute/Ax.tsx

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import React, { useEffect } from 'react';
2+
import { JSONTree } from 'react-json-tree'; // React JSON Viewer Component;
3+
import { setCurrentTabInApp } from '../../slices/mainSlice';
4+
import { useDispatch } from 'react-redux';
5+
6+
// const getItemString = (
7+
// type: any,
8+
// data: { state?: object | string; name: string; children: [] },
9+
// ) => {
10+
// // function that allows the customization of how arrays, objects, and iterable nodes are displayed.
11+
// if (data && data.name) {
12+
// return <span>{data.name}</span>;
13+
// }
14+
// return <span />;
15+
// };
16+
const theme = {
17+
scheme: 'monokai',
18+
author: 'wimer hazenberg (http://www.monokai.nl)',
19+
base00: '#272822',
20+
base01: '#383830',
21+
base02: '#49483e',
22+
base03: '#75715e',
23+
base04: '#a59f85',
24+
base05: '#f8f8f2',
25+
base06: '#f5f4f1',
26+
base07: '#f9f8f5',
27+
base08: '#f92672',
28+
base09: '#fd971f',
29+
base0A: '#f4bf75',
30+
base0B: '#a6e22e',
31+
base0C: '#a1efe4',
32+
base0D: '#66d9ef',
33+
base0E: '#ae81ff',
34+
base0F: '#cc6633',
35+
};
36+
37+
const AxTree = (props) => {
38+
const {
39+
snapshot, // from 'tabs[currentTab]' object in 'MainContainer'
40+
snapshots, // from 'tabs[currentTab].snapshotDisplay' object in 'MainContainer'
41+
currLocation, // from 'tabs[currentTab]' object in 'MainContainer'
42+
} = props;
43+
44+
const dispatch = useDispatch();
45+
46+
useEffect(() => {
47+
dispatch(setCurrentTabInApp('AxTree')); // dispatch sent at initial page load allowing changing "immer's" draft.currentTabInApp to 'tree' to facilitate render.
48+
}, []);
49+
// const json = {
50+
// array: [1, 2, 3],
51+
// bool: true,
52+
// object: {
53+
// foo: 'bar',
54+
// },
55+
// };
56+
57+
//removing/adding snapshot at beginning of return statement didn't change anything
58+
return(
59+
<> {snapshot && (
60+
<JSONTree
61+
data={snapshots[currLocation.index] || snapshot}
62+
shouldExpandNodeInitially={() => true}
63+
theme = {theme}
64+
/>
65+
)}
66+
</>
67+
)
68+
}
69+
export default AxTree;

src/app/components/StateRoute/StateRoute.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { useSelector } from 'react-redux';
1515
import PerformanceVisx from './PerformanceVisx/PerformanceVisx';
1616
import WebMetricsContainer from './WebMetrics/WebMetricsContainer';
1717
import { MainState, RootState, StateRouteProps } from '../../FrontendTypes';
18+
import AxTree from './Ax';
1819

1920
/*
2021
Loads the appropriate StateRoute view and renders the Map, Performance, History, Webmetrics, and Tree navbar buttons after clicking on the 'State' button located near the top rightmost corner.
@@ -84,9 +85,25 @@ const StateRoute = (props: StateRouteProps) => {
8485
>
8586
Tree
8687
</NavLink>
88+
<NavLink
89+
className = {(navData) =>
90+
navData.isActive ? 'is-active router-link accessibility-tab' : 'router-link accessibility-tab'
91+
}
92+
to = '/accessibility'
93+
>
94+
Accessibility
95+
</NavLink>
8796
</div>
8897
<div className='app-content'>
8998
<Routes>
99+
<Route
100+
path = '/accessibility'
101+
element = {<AxTree
102+
snapshot={snapshot}
103+
snapshots={snapshots}
104+
currLocation={currLocation}/>}
105+
>
106+
</Route>
90107
<Route
91108
path='/history'
92109
element={

0 commit comments

Comments
 (0)