Skip to content

Commit 7174d17

Browse files
authored
Merge pull request #36 from oslabs-beta/josh/react-router
implemented react-router and fixed tree component from changing size of outer div
2 parents 95d8d76 + f835308 commit 7174d17

File tree

11 files changed

+206
-80
lines changed

11 files changed

+206
-80
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: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
import JSONTree from 'react-json-tree';
3+
4+
const getItemString = (type, data, itemType, itemString) => (
5+
<span>
6+
//
7+
{type}
8+
</span>
9+
);
10+
11+
const Tree = (props) => {
12+
const { snapshot } = props;
13+
console.log('TREE COMPONENT IS PRINTED');
14+
console.log(snapshot);
15+
return (
16+
<React.Fragment>
17+
{snapshot && (
18+
<JSONTree
19+
data={snapshot}
20+
theme={{ tree: () => ({ className: 'json-tree' }) }}
21+
getItemString={getItemString}
22+
/>
23+
)}
24+
</React.Fragment>
25+
);
26+
};
27+
export default Tree;

src/app/containers/StateContainer.jsx

Lines changed: 19 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,34 @@
11
import React, { Component } from 'react';
2-
import JSONTree from 'react-json-tree';
3-
import * as themes from 'redux-devtools-themes';
4-
5-
const getItemString = (type, data, itemType, itemString) => (
6-
<span>
7-
//
8-
{type}
9-
</span>
10-
);
2+
import { MemoryRouter as Router, Route, NavLink } from 'react-router-dom';
3+
import Tree from '../components/Tree';
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;
2013
return (
21-
<div className="state-container">
22-
{snapshot && (
23-
<JSONTree
24-
data={snapshot}
25-
theme={{ tree: () => ({ className: 'json-tree' }) }}
26-
getItemString={getItemString}
27-
/>
28-
)}
29-
</div>
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>
3028
);
3129
}
3230
}
31+
{
32+
}
3333

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

src/app/containers/TravelContainer.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import MainSlider from '../components/MainSlider'
2+
import MainSlider from '../components/MainSlider';
33

44
const TravelContainer = ({
55
playForward,

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/components/_buttons.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,17 @@
99
visibility: hidden;
1010
}
1111

12+
.jump-button:focus {
13+
outline: 0;
14+
// make the text in the button not highlightable
15+
-webkit-user-select: none; /* Safari */
16+
-moz-user-select: none; /* Firefox */
17+
-ms-user-select: none; /* IE10+/Edge */
18+
user-select: none; /* Standard */
19+
}
20+
1221
.jump-button:hover {
22+
// remove the blue border when button is clicked
1323
background-color: $highlight-color;
1424
}
1525

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
.json-tree {
2-
margin: 0;
3-
padding: 10px;
2+
position: absolute;
3+
margin: 10px;
4+
padding: 0;
45
background-color: $brand-color;
56
list-style: none;
6-
min-width: 300px;
7+
// overflow: hidden;
78
}

0 commit comments

Comments
 (0)