Skip to content

Commit 6065fa0

Browse files
committed
display tree frameworks working. added google charts dependancy to package.json. Added redux functionality for assigning context
Co-authored-by: Sal Saluga [email protected] Co-authored-by: Bianca Picasso [email protected] Co-authored-by: Huy Pham [email protected]
1 parent aba81bc commit 6065fa0

File tree

5 files changed

+71
-12
lines changed

5 files changed

+71
-12
lines changed
Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,50 @@
1-
import { Typography } from '@material-ui/core';
2-
import React from 'react';
1+
import React, { useEffect } from 'react';
2+
import { useStore } from 'react-redux';
3+
import { Chart } from 'react-google-charts';
34

45
const DisplayContainer = () => {
5-
return (
6-
<Typography variant="h1" align="center">
7-
Beautiful Tree
8-
</Typography>
9-
);
10-
};
6+
const store = useStore();
117

8+
useEffect(() => {
9+
console.log(store.getState().contextSlice);
10+
}, []);
1211

1312

14-
export default DisplayContainer;
13+
const data = [
14+
['Phrases'],
15+
['cats are better than dogs'],
16+
['cats eat kibble'],
17+
['cats are better than hamsters'],
18+
['cats are awesome'],
19+
['cats are people too'],
20+
['cats eat mice'],
21+
['cats meowing'],
22+
['cats in the cradle'],
23+
['cats eat mice'],
24+
['cats in the cradle lyrics'],
25+
['cats eat kibble'],
26+
['cats for adoption'],
27+
['cats are family'],
28+
['cats eat mice'],
29+
['cats are better than kittens'],
30+
['cats are evil'],
31+
['cats are weird'],
32+
['cats eat mice'],
33+
];
34+
const options = {
35+
wordtree: {
36+
format: 'implicit',
37+
word: 'cats',
38+
},
39+
};
40+
return (
41+
<Chart
42+
chartType='WordTree'
43+
width='100%'
44+
height='400px'
45+
data={data}
46+
options={options}
47+
/>
48+
);
49+
};
50+
export default DisplayContainer;

app/src/redux/actions/actions.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ export const addContextValuesActionCreator = newEntry => ({
1313
type: types.ADD_CONTEXT_VALUES,
1414
payload: newEntry
1515
});
16+
17+
export const addComponentToContext = newEntry => ({
18+
type: types.ADD_COMPONENT_TO_CONTEXT,
19+
payload: newEntry
20+
});

app/src/redux/constants/actionTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ export const CODE_PREVIEW_SAVE = 'CODE_PREVIEW_SAVE';
44
export const CODE_PREVIEW_INPUT = 'CODE_PREVIEW_INPUT';
55
export const ADD_CONTEXT = 'ADD_CONTEXT';
66
export const ADD_CONTEXT_VALUES = 'ADD_CONTEXT_VALUES';
7+
export const ADD_COMPONENT_TO_CONTEXT = 'ADD_COMPONENT_TO_CONTEXT';

app/src/redux/reducers/slice/contextReducer.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ const initialState = {
77
values: [
88
{ key: 'testKey1', value: 'testValue1' },
99
{ key: 'testKey2', value: 'testValue2' }
10-
]
10+
],
11+
components: []
1112
},
1213
{
1314
name: 'MainContext3',
1415
values: [
1516
{ key: 'testKey3', value: 'testValue3' },
1617
{ key: 'testKey33', value: 'testValue33' }
17-
]
18+
],
19+
components: []
1820
}
1921
]
2022
};
@@ -24,7 +26,8 @@ const contextReducer = (state = initialState, action) => {
2426
case types.ADD_CONTEXT:
2527
const newContext = {
2628
name: action.payload.name.trim(),
27-
values: []
29+
values: [],
30+
components: []
2831
};
2932

3033
return {
@@ -50,6 +53,19 @@ const contextReducer = (state = initialState, action) => {
5053
...state,
5154
allContext: newAllContext
5255
};
56+
case types.ADD_COMPONENT_TO_CONTEXT:
57+
const newTempState = [...state.allContext];
58+
59+
for (let i = 0; i < newTempState.length; i += 1) {
60+
if (newTempState[i].name === action.payload.context) {
61+
newTempState[i].components.push(action.payload.component);
62+
}
63+
}
64+
65+
return {
66+
...state,
67+
allContext: newTempState
68+
};
5369
default: {
5470
return state;
5571
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@
155155
"re-resizable": "^6.7.0",
156156
"react-dnd": "^11.1.3",
157157
"react-dnd-html5-backend": "^11.1.3",
158+
"react-google-charts": "^4.0.0",
158159
"react-google-login": "^5.1.22",
159160
"react-router-dom": "^5.2.0",
160161
"redux-devtools-extension": "^2.13.9",

0 commit comments

Comments
 (0)