Skip to content

Commit 82480a0

Browse files
committed
added react-router to switch between tree and chart component
1 parent 44fb14f commit 82480a0

File tree

8 files changed

+174
-63
lines changed

8 files changed

+174
-63
lines changed

package-lock.json

Lines changed: 103 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"react": "^16.8.6",
5252
"react-dom": "^16.8.6",
5353
"react-json-tree": "^0.11.2",
54+
"react-router-dom": "^5.0.1",
5455
"redux-devtools-themes": "^1.0.0",
5556
"sass": "^1.22.7"
5657
}

src/app/components/Chart.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import React from 'react';
2+
3+
const Chart = props => <div>Chart</div>;
4+
5+
export default Chart;

src/app/components/Tree.jsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ const getItemString = (type, data, itemType, itemString) => (
1010

1111
const Tree = (props) => {
1212
const { snapshot } = props;
13+
console.log('TREE COMPONENT IS PRINTED');
14+
console.log(snapshot);
1315
return (
14-
<JSONTree
15-
data={snapshot}
16-
theme={{ tree: () => ({ className: 'json-tree' }) }}
17-
getItemString={getItemString}
18-
/>
16+
<React.Fragment>
17+
{snapshot && (
18+
<JSONTree
19+
data={snapshot}
20+
theme={{ tree: () => ({ className: 'json-tree' }) }}
21+
getItemString={getItemString}
22+
/>
23+
)}
24+
</React.Fragment>
1925
);
2026
};
2127
export default Tree;

src/app/containers/StateContainer.jsx

Lines changed: 20 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,34 @@
11
import React, { Component } from 'react';
2-
import * as themes from 'redux-devtools-themes';
2+
import { MemoryRouter as Router, Route, NavLink } from 'react-router-dom';
33
import Tree from '../components/Tree';
4-
5-
const getItemString = (type, data, itemType, itemString) => (
6-
<span>
7-
//
8-
{type}
9-
</span>
10-
);
4+
import Chart from '../components/Chart';
115

126
class StateContainer extends Component {
137
constructor(props) {
148
super(props);
15-
console.log(themes);
169
}
1710

1811
render() {
1912
const { snapshot } = this.props;
20-
return <div className="state-container">{snapshot && <Tree snapshot={snapshot} />}</div>;
13+
return (
14+
<Router>
15+
<div className="state-container">
16+
<div className="navbar">
17+
<NavLink className="router-link" activeClassName="is-active" to="/tree">
18+
Tree
19+
</NavLink>
20+
<NavLink className="router-link" activeClassName="is-active" to="/chart">
21+
Chart
22+
</NavLink>
23+
</div>
24+
<Route path="/tree" render={() => <Tree snapshot={snapshot} />} />
25+
<Route path="/chart" render={() => <Chart snapshot={snapshot} />} />
26+
</div>
27+
</Router>
28+
);
2129
}
2230
}
31+
{
32+
}
2333

2434
export default StateContainer;
25-
26-
// const theme = {
27-
// scheme: 'monokai',
28-
// author: 'wimer hazenberg (http://www.monokai.nl)',
29-
// base00: '#272822',
30-
// base01: '#383830',
31-
// base02: '#49483e',
32-
// base03: '#75715e',
33-
// base04: '#a59f85',
34-
// base05: '#f8f8f2',
35-
// base06: '#f5f4f1',
36-
// base07: '#f9f8f5',
37-
// base08: '#f92672',
38-
// base09: '#fd971f',
39-
// base0A: '#f4bf75',
40-
// base0B: '#a6e22e',
41-
// base0C: '#a1efe4',
42-
// base0D: '#66d9ef',
43-
// base0E: '#ae81ff',
44-
// base0F: '#cc6633',
45-
// };
46-
47-
// const theme = {
48-
// scheme: 'nicinabox',
49-
// author: 'nicinabox (http://github.com/nicinabox)',
50-
// base00: '#2A2F3A',
51-
// base01: '#3C444F',
52-
// base02: '#4F5A65',
53-
// base03: '#BEBEBE',
54-
// base04: '#b0b0b0', // based on ocean theme
55-
// base05: '#d0d0d0', // based on ocean theme
56-
// base06: '#FFFFFF',
57-
// base07: '#f5f5f5', // based on ocean theme
58-
// base08: '#fb9fb1', // based on ocean theme
59-
// base09: '#FC6D24',
60-
// base0A: '#ddb26f', // based on ocean theme
61-
// base0B: '#A1C659',
62-
// base0C: '#12cfc0', // based on ocean theme
63-
// base0D: '#6FB3D2',
64-
// base0E: '#D381C3',
65-
// base0F: '#deaf8f', // based on ocean theme
66-
// };

src/app/containers/TravelContainer.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { Component } from 'react';
2+
23
import Slider from '../components/Slider';
34

45
class TravelContainer extends Component {

src/app/styles/abstracts/_variables.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ $light-grey-one: #474c55 !default;
1616
/// @type Color
1717
$light-grey-two: #5f6369 !default;
1818

19+
$light-grey-three: rgb(101, 104, 110) !default;
20+
21+
/// @type Color
22+
$navbar-color: rgb(68, 72, 78) !default;
23+
1924
/// @type Color
2025
$border-color: rgba(190, 190, 190, 0.5) !default;
2126

src/app/styles/layout/_stateContainer.scss

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,31 @@
66
background-color: $brand-color;
77
}
88

9-
// .state-container ul {
10-
// background-color: $brand-color;
11-
// }
9+
.state-container .navbar {
10+
background-color: $navbar-color;
11+
display: flex;
12+
flex-direction: row;
13+
justify-content: flex-start;
14+
align-items: center;
15+
height: 30px;
16+
}
17+
18+
.state-container {
19+
.router-link {
20+
height: 100%;
21+
width: 80px;
22+
display: flex;
23+
justify-content: center;
24+
align-items: center;
25+
background-color: $navbar-color;
26+
text-decoration: none;
27+
color: $text-color;
28+
}
29+
.router-link:hover {
30+
background-color: $light-grey-three;
31+
}
32+
33+
.router-link.is-active {
34+
background-color: $brand-color;
35+
}
36+
}

0 commit comments

Comments
 (0)