Skip to content

Commit c0bd206

Browse files
committed
successfully creating a mimicked fiber tree structure rendered in new accessibility react tab. Next just have to form the connectiong to our accessibility tree instead
1 parent 64846b4 commit c0bd206

File tree

2 files changed

+68
-12
lines changed

2 files changed

+68
-12
lines changed

src/app/components/StateRoute/Ax.tsx

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,69 @@
1-
import React from 'react';
2-
import { JSONTree } from 'react-json-tree'; // React JSON Viewer Component
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';
35

4-
const json = {
5-
array: [1, 2, 3],
6-
bool: true,
7-
object: {
8-
foo: 'bar',
9-
},
10-
}
11-
const AxTree = () => {
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
1258
return(
13-
<JSONTree data={json} />
59+
<> {snapshot && (
60+
<JSONTree
61+
data={snapshots[currLocation.index] || snapshot}
62+
shouldExpandNodeInitially={() => true}
63+
theme = {theme}
64+
/>
65+
)}
66+
</>
1467
)
1568
}
1669
export default AxTree;

src/app/components/StateRoute/StateRoute.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ const StateRoute = (props: StateRouteProps) => {
9898
<Routes>
9999
<Route
100100
path = '/accessibility'
101-
element = {<AxTree/>}
101+
element = {<AxTree
102+
snapshot={snapshot}
103+
snapshots={snapshots}
104+
currLocation={currLocation}/>}
102105
>
103106
</Route>
104107
<Route

0 commit comments

Comments
 (0)