Skip to content

Commit 4245ed3

Browse files
authored
Merge pull request #7 from oslabs-beta/josh/extensions
Josh/extensions
2 parents b35cada + e4ed574 commit 4245ed3

File tree

13 files changed

+1410
-1243
lines changed

13 files changed

+1410
-1243
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
3+
4+
const Action = (props) => {
5+
const { snapshot } = props;
6+
return <div className="action-component">{snapshot.state}</div>;
7+
};
8+
9+
Action.propTypes = {
10+
// snapshot: PropTypes.object,
11+
};
12+
13+
export default Action;

extension/app/components/App.jsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import React, { Component } from 'react';
2+
import MainContainer from '../containers/MainContainer';
23

3-
const App = () => (
4-
<div>
5-
App
6-
</div>
7-
);
4+
const App = () => <MainContainer />;
85

96
export default App;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React, { Component } from 'react';
2+
import Action from '../components/Action';
3+
4+
class ActionContainer extends Component {
5+
constructor(props) {
6+
super(props);
7+
}
8+
9+
render() {
10+
const { snapshots } = this.props;
11+
let actionsArr = [];
12+
if (snapshots) {
13+
actionsArr = snapshots.map((snapshot, index) => (
14+
<Action key={`action${index}`} snapshot={snapshot} />
15+
));
16+
}
17+
return <div className="action-container">{actionsArr}</div>;
18+
}
19+
}
20+
21+
export default ActionContainer;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React, { Component } from 'react';
2+
3+
class HeadContainer extends Component {
4+
constructor() {
5+
super();
6+
}
7+
8+
render() {
9+
return <div className="head-container">HeadContainer</div>;
10+
}
11+
}
12+
13+
export default HeadContainer;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React, { Component } from 'react';
2+
import HeadContainer from './HeadContainer';
3+
import ActionContainer from './ActionContainer';
4+
import StateContainer from './StateContainer';
5+
import TravelContainer from './TravelContainer';
6+
7+
class MainContainer extends Component {
8+
constructor() {
9+
super();
10+
this.state = { snapshots: [] };
11+
}
12+
13+
componentDidMount() {
14+
// add a listener to capture messages from our backend
15+
// this should be in the inject script
16+
// window.addEventListener(
17+
// 'message',
18+
// (event) => {
19+
// // We only accept messages from ourselves
20+
// if (event.source !== window) return;
21+
// console.log(`Message received from backend: ${event.payload}`);
22+
// },
23+
// false,
24+
// );
25+
26+
// MOCK DATA -- FOR TESTING PURPOSES ONLY
27+
this.setState({
28+
snapshots: [{ state: 'snapshot1' }, { state: 'snapshot2' }, { state: 'snapshot3' }],
29+
});
30+
}
31+
32+
render() {
33+
const { snapshots } = this.state;
34+
35+
return (
36+
<div className="main-container">
37+
<HeadContainer />
38+
<div className="body-container">
39+
<ActionContainer snapshots={snapshots} />
40+
<StateContainer />
41+
</div>
42+
<TravelContainer />
43+
</div>
44+
);
45+
}
46+
}
47+
48+
export default MainContainer;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React, { Component } from 'react';
2+
3+
class StateContainer extends Component {
4+
constructor() {
5+
super();
6+
}
7+
8+
render() {
9+
return <div className="state-container">StateContainer</div>;
10+
}
11+
}
12+
13+
export default StateContainer;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React, { Component } from 'react';
2+
3+
class TravelContainer extends Component {
4+
constructor() {
5+
super();
6+
}
7+
8+
render() {
9+
return <div className="travel-container">TravelContainer</div>;
10+
}
11+
}
12+
13+
export default TravelContainer;

extension/app/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
33
import App from './components/App';
4+
import styles from './styles/styles.css';
45

5-
ReactDOM.render(
6-
<App />, document.getElementById('root'),
7-
);
6+
ReactDOM.render(<App />, document.getElementById('root'));

extension/app/styles/panel.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
html {
2+
height: 100%;
3+
}
4+
5+
body {
6+
margin: 0;
7+
height: 100%;
8+
}
9+
10+
#root {
11+
height: 100%;
12+
}

extension/app/styles/styles.css

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
.main-container {
2+
height: 100%;
3+
margin: 0;
4+
padding: 0;
5+
background-color: rgb(238, 238, 238);
6+
}
7+
8+
.head-container {
9+
height: 10%;
10+
}
11+
12+
.body-container {
13+
height: 80%;
14+
width: 100%;
15+
display: flex;
16+
flex-wrap: wrap;
17+
}
18+
19+
.action-container {
20+
flex: 3 auto;
21+
}
22+
23+
.state-container {
24+
flex: 7 auto;
25+
}
26+
27+
/* if extension width is less than 500px, stack the body containers */
28+
@media (max-width: 500px) {
29+
.body-container {
30+
flex-direction: column;
31+
}
32+
.state-container {
33+
flex: 3 auto;
34+
}
35+
}
36+
37+
.travel-container {
38+
height: 10%;
39+
}
40+
41+
.head-container,
42+
.body-container,
43+
.action-container,
44+
.state-container,
45+
.travel-container {
46+
border-style: solid;
47+
border-color: black;
48+
border-width: thin;
49+
}
50+
51+
.action-component {
52+
height: 40px;
53+
width: 100%;
54+
background-color: rgb(170, 170, 170);
55+
border-style: solid;
56+
border-width: thin;
57+
}

0 commit comments

Comments
 (0)