Skip to content

Commit 95d8d76

Browse files
authored
Merge pull request #35 from oslabs-beta/rydang/responsive
responsive design for containers, also hidden jump button
2 parents 71180fa + 8c40b5c commit 95d8d76

File tree

10 files changed

+84
-91
lines changed

10 files changed

+84
-91
lines changed

package/tree.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Tree {
1919
}
2020

2121
// deep copies only the state of each component and creates a new tree
22-
getCopy(copy = new Tree('root', true, 'root')) {
22+
getCopy(copy = new Tree('root', true)) {
2323
// copy state of children
2424
copy.children = this.children.map(child => new Tree(child.component.state, true, child.component.constructor.name));
2525

src/app/containers/MainContainer.jsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,33 +44,33 @@ class MainContainer extends Component {
4444
this.setState({ port });
4545
}
4646

47-
moveBackward(){
47+
moveBackward() {
4848
const { snapshots, snapshotIndex } = this.state;
49-
if(snapshots.length>0 && snapshotIndex>0) {
50-
const newIndex = snapshotIndex-1;
49+
if (snapshots.length > 0 && snapshotIndex > 0) {
50+
const newIndex = snapshotIndex - 1;
5151
this.handleJumpSnapshot(newIndex);
5252
this.setState({ snapshotIndex: newIndex });
5353
}
5454
}
5555

56-
moveForward(){
56+
moveForward() {
5757
const { snapshots, snapshotIndex } = this.state;
58-
if(snapshotIndex<snapshots.length-1){
59-
const newIndex = snapshotIndex+1;
58+
if (snapshotIndex < snapshots.length - 1) {
59+
const newIndex = snapshotIndex + 1;
6060
this.handleJumpSnapshot(newIndex);
6161
this.setState({ snapshotIndex: newIndex });
6262
}
6363
}
6464

65-
playForward(){
66-
var play = setInterval(()=>{
65+
playForward() {
66+
var play = setInterval(() => {
6767
const { snapshots, snapshotIndex } = this.state;
68-
if(snapshotIndex<snapshots.length-1){
69-
const newIndex = snapshotIndex+1;
68+
if (snapshotIndex < snapshots.length - 1) {
69+
const newIndex = snapshotIndex + 1;
7070
this.handleJumpSnapshot(newIndex);
7171
this.setState({ snapshotIndex: newIndex });
7272
} else clearInterval(play);
73-
},1000)
73+
}, 1000)
7474
play();
7575
}
7676

@@ -137,16 +137,16 @@ class MainContainer extends Component {
137137
emptySnapshot={this.emptySnapshot}
138138
/>
139139
<StateContainer snapshot={snapshots[snapshotIndex]} />
140+
<TravelContainer
141+
snapshotsLength={snapshots.length}
142+
handleChangeSnapshot={this.handleChangeSnapshot}
143+
handleJumpSnapshot={this.handleJumpSnapshot}
144+
snapshotIndex={snapshotIndex}
145+
moveBackward={this.moveBackward}
146+
moveForward={this.moveForward}
147+
playForward={this.playForward}
148+
/>
140149
</div>
141-
<TravelContainer
142-
snapshotsLength={snapshots.length}
143-
handleChangeSnapshot={this.handleChangeSnapshot}
144-
handleJumpSnapshot={this.handleJumpSnapshot}
145-
snapshotIndex={snapshotIndex}
146-
moveBackward = {this.moveBackward}
147-
moveForward = {this.moveForward}
148-
playForward = {this.playForward}
149-
/>
150150
</div>
151151
);
152152
}
Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,31 @@
1-
import React, { Component } from 'react';
1+
import React from 'react';
22
import MainSlider from '../components/MainSlider'
33

4-
5-
6-
7-
class TravelContainer extends Component {
8-
constructor(props) {
9-
super(props);
10-
}
11-
12-
13-
14-
render() {
15-
return (
16-
<div className="travel-container">
17-
<div className="play-button" onClick={this.props.playForward}>
18-
play
19-
</div>
20-
<MainSlider
21-
snapshotLength = {this.props.snapshotsLength}
22-
handleChangeSnapshot = {this.props.handleChangeSnapshot}
23-
snapshotIndex = {this.props.snapshotIndex}
24-
handleJumpSnapshot={this.props.handleJumpSnapshot}
25-
/>
26-
<div className="backward-button" onClick={this.props.moveBackward}>
27-
{'<'}
28-
</div>
29-
<div className="forward-button" onClick={this.props.moveForward}>
30-
{'>'}
31-
</div>
32-
</div>
33-
);
34-
}
35-
}
4+
const TravelContainer = ({
5+
playForward,
6+
moveBackward,
7+
moveForward,
8+
snapshotsLength,
9+
handleChangeSnapshot,
10+
handleJumpSnapshot,
11+
snapshotIndex,
12+
}) => (
13+
<div className="travel-container">
14+
<div className="play-button" onClick={playForward}>
15+
play
16+
</div>
17+
<MainSlider
18+
snapshotLength={snapshotsLength}
19+
handleChangeSnapshot={handleChangeSnapshot}
20+
snapshotIndex={snapshotIndex}
21+
handleJumpSnapshot={handleJumpSnapshot}
22+
/>
23+
<div className="backward-button" onClick={moveBackward}>
24+
{'<'}
25+
</div>
26+
<div className="forward-button" onClick={moveForward}>
27+
{'>'}
28+
</div>
29+
</div>
30+
);
3631
export default TravelContainer;

src/app/styles/components/_actionComponent.scss

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.action-component {
22
padding: 5px 10px;
3-
display: flex;
4-
justify-content: space-around;
3+
display: grid;
4+
grid-template-columns: 5fr 1fr;
55
align-items: center;
66
height: 20px;
77
background-color: $brand-color;
@@ -18,5 +18,8 @@
1818

1919
.action-component button {
2020
position: relative;
21-
right: 0px;
21+
}
22+
23+
.action-component:hover .jump-button {
24+
visibility: visible;
2225
}

src/app/styles/components/_buttons.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
.jump-button {
77
@extend %button-shared;
88
width: 50px;
9+
visibility: hidden;
910
}
1011

1112
.jump-button:hover {
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
.action-container {
2-
flex: 3 auto;
3-
height: 100%;
4-
overflow: scroll;
2+
overflow: auto;
53
background-color: $brand-color;
64
}
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
.state-container {
2-
font-size: 15px;
3-
flex: 6 auto;
4-
height: 100%;
5-
overflow: scroll;
2+
font-size: 12px;
3+
overflow: auto;
64
background-color: $brand-color;
75
}
8-
9-
// .state-container ul {
10-
// background-color: $brand-color;
11-
// }
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
.travel-container {
2-
height: 20%;
32
display: flex;
43
flex-direction: row;
54
align-items: center;
65
justify-content: space-around;
7-
}
6+
}

src/app/styles/styles.scss

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,50 @@
11
.main-container {
22
height: 100%;
3-
margin: 0;
4-
padding: 0;
3+
margin: 0 auto;
4+
padding: 0 auto;
55
background-color: $brand-color;
6+
overflow: hidden;
67
}
78

89
.head-container {
910
height: 5%;
1011
}
1112

1213
.body-container {
13-
height: 75%;
14+
height: 95%;
1415
width: 100%;
15-
display: flex;
16-
flex-wrap: wrap;
16+
display: grid;
17+
grid-template-rows: 8fr 1fr;
18+
grid-template-areas:
19+
"actions states"
20+
"travel travel";
1721
}
1822

1923

2024
/* if extension width is less than 500px, stack the body containers */
2125
// this is not working for some reason
2226
@media (max-width: 500px) {
2327
.body-container {
24-
flex-direction: column;
25-
}
26-
.state-container {
27-
// flex: 5 auto;
28+
grid-template-rows: 4fr 4fr 1fr;
29+
grid-template-areas:
30+
"actions"
31+
"states"
32+
"travel";
2833
}
2934
}
35+
.travel-container {
36+
grid-area: travel;
37+
}
3038

39+
.action-container {
40+
grid-area: actions;
41+
}
42+
.state-container {
43+
grid-area: states;
44+
}
3145
.emptySnapshot{
3246
width: 100%;
3347
}
34-
35-
36-
37-
3848
.head-container,
3949
.body-container,
4050
.action-container,
@@ -43,4 +53,4 @@
4353
border-style: solid;
4454
border-color: $border-color;
4555
border-width: thin;
46-
}
56+
}

src/extension/tree.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)