Skip to content

Bryan/slider scss #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jul 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,171 changes: 2,095 additions & 2,076 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import React, { Component } from 'react';
import Slider from 'rc-slider';
import Tooltip from 'rc-tooltip';

import 'rc-slider/assets/index.css';
import 'rc-tooltip/assets/bootstrap.css';

const { Handle } = Slider;

Expand Down Expand Up @@ -32,7 +30,6 @@ class mainSlider extends Component {

render() {
return (
<div>
<Slider
min={0}
max={this.props.snapshotLength - 1}
Expand All @@ -44,7 +41,6 @@ class mainSlider extends Component {
}}
handle={handle}
/>
</div>
);
}
}
Expand Down
39 changes: 37 additions & 2 deletions src/app/containers/MainContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class MainContainer extends Component {
this.handleSendSnapshot = this.handleSendSnapshot.bind(this);
this.handleJumpSnapshot = this.handleJumpSnapshot.bind(this);
this.emptySnapshot = this.emptySnapshot.bind(this);
this.moveBackward = this.moveBackward.bind(this);
this.moveForward = this.moveForward.bind(this);
this.playForward = this.playForward.bind(this);
}

componentDidMount() {
Expand All @@ -41,14 +44,43 @@ class MainContainer extends Component {
this.setState({ port });
}

moveBackward(){
const { snapshots, snapshotIndex } = this.state;
if(snapshots.length>0 && snapshotIndex>0) {
const newIndex = snapshotIndex-1;
this.handleJumpSnapshot(newIndex);
this.setState({ snapshotIndex: newIndex });
}
}

moveForward(){
const { snapshots, snapshotIndex } = this.state;
if(snapshotIndex<snapshots.length-1){
const newIndex = snapshotIndex+1;
this.handleJumpSnapshot(newIndex);
this.setState({ snapshotIndex: newIndex });
}
}

playForward(){
var play = setInterval(()=>{
const { snapshots, snapshotIndex } = this.state;
if(snapshotIndex<snapshots.length-1){
const newIndex = snapshotIndex+1;
this.handleJumpSnapshot(newIndex);
this.setState({ snapshotIndex: newIndex });
} else clearInterval(play);
},1000)
play();
}

emptySnapshot() {
const { port } = this.state;
this.setState({ snapshots: [], snapshotIndex: 0 });
port.postMessage({ action: 'emptySnap' });
}

// change the snapshot index
// this will change the state shown in the state container but won't change the DOM
// change the snapshot index, this will change the state shown in the state container but won't change the DOM
handleChangeSnapshot(snapshotIndex) {
// snapshotIndex
// --> 1. affects the action that is highlighted
Expand Down Expand Up @@ -111,6 +143,9 @@ class MainContainer extends Component {
handleChangeSnapshot={this.handleChangeSnapshot}
handleJumpSnapshot={this.handleJumpSnapshot}
snapshotIndex={snapshotIndex}
moveBackward = {this.moveBackward}
moveForward = {this.moveForward}
playForward = {this.playForward}
/>
</div>
);
Expand Down
29 changes: 20 additions & 9 deletions src/app/containers/TravelContainer.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
import React, { Component } from 'react';
import Slider from '../components/Slider';
import MainSlider from '../components/MainSlider'




class TravelContainer extends Component {
constructor(props) {
super(props);
}



render() {
return (
<div>
<div className="travel-container">TravelContainer</div>
<Slider
className="travel-slider"
snapshotLength={this.props.snapshotsLength}
handleChangeSnapshot={this.props.handleChangeSnapshot}
<div className="travel-container">
<div className="play-button" onClick={this.props.playForward}>
play
</div>
<MainSlider
snapshotLength = {this.props.snapshotsLength}
handleChangeSnapshot = {this.props.handleChangeSnapshot}
snapshotIndex = {this.props.snapshotIndex}
handleJumpSnapshot={this.props.handleJumpSnapshot}
snapshotIndex={this.props.snapshotIndex}
/>
{`travelContainer snapshotIndex ${this.props.snapshotIndex}`}
<div className="backward-button" onClick={this.props.moveBackward}>
{'<'}
</div>
<div className="forward-button" onClick={this.props.moveForward}>
{'>'}
</div>
</div>
);
}
Expand Down
18 changes: 18 additions & 0 deletions src/app/styles/components/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@
background-color: $highlight-color;
}

.play-button {
@extend %button-shared;
width: 60px;
margin: 10px;
}

.backward-button {
@extend %button-shared;
width: 30px;
margin: 7px;
}

.forward-button {
@extend %button-shared;
width: 30px;
margin: 7px;
}

%button-shared {
display: flex;
justify-content: center;
Expand Down
Loading