Skip to content

Commit f27a34b

Browse files
committed
added playback dropdown component
1 parent 9408dc0 commit f27a34b

File tree

3 files changed

+55
-28
lines changed

3 files changed

+55
-28
lines changed

src/app/containers/MainContainer.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class MainContainer extends Component {
1919
snapshotIndex: 0,
2020
port: null,
2121
playing: false,
22-
playSpeed: 1000,
2322
mode: {
2423
locked: false,
2524
paused: false,

src/app/containers/TravelContainer.jsx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,26 @@ import PropTypes from 'prop-types';
33
import Select from 'react-select';
44
import MainSlider from '../components/MainSlider';
55

6+
const options = [
7+
{ value: '2000', label: '0.5x' },
8+
{ value: '1000', label: '1.0x' },
9+
{ value: '500', label: '2.0x' },
10+
];
11+
612
class TravelContainer extends Component {
713
constructor(props) {
814
super(props);
9-
this.state = { playSpeed: 1000 };
15+
this.state = { playSpeed: 1000, selectedOption: options[1] };
16+
this.handleChangeSpeed = this.handleChangeSpeed.bind(this);
17+
}
18+
19+
handleChangeSpeed(selectedOption) {
20+
const playSpeed = parseInt(selectedOption.value, 10);
21+
this.setState({ selectedOption, playSpeed });
1022
}
1123

1224
render() {
13-
const { playSpeed } = this.state;
25+
const { playSpeed, selectedOption } = this.state;
1426
const {
1527
moveBackward,
1628
moveForward,
@@ -23,22 +35,9 @@ class TravelContainer extends Component {
2335
pause,
2436
} = this.props;
2537

26-
const options = [
27-
{ value: '2000', label: '0.5x' },
28-
{ value: '1000', label: '1.0x' },
29-
{ value: '500', label: '2.0x' },
30-
];
31-
const selectedOption = options[0];
32-
3338
return (
3439
<div className="travel-container">
35-
<div
36-
className="play-button"
37-
onClick={() => {
38-
play(playSpeed);
39-
console.log('play clicked');
40-
}}
41-
>
40+
<div className="play-button" onClick={() => play(playSpeed)}>
4241
{playing ? 'Pause' : 'Play'}
4342
</div>
4443
<MainSlider
@@ -54,13 +53,14 @@ class TravelContainer extends Component {
5453
<div className="forward-button" role="button" onClick={moveForward}>
5554
{'>'}
5655
</div>
57-
{/* <Select
58-
value={selectedOption}
59-
onChange={() => {
60-
console.log('select => value changed');
61-
}}
62-
options={options}
63-
/> */}
56+
<Select
57+
className="react-select-container"
58+
classNamePrefix="react-select"
59+
value={selectedOption}
60+
onChange={this.handleChangeSpeed}
61+
options={options}
62+
menuPlacement="top"
63+
/>
6464
</div>
6565
);
6666
}
Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
.travel-container {
2-
display: flex;
3-
flex-direction: row;
4-
align-items: center;
5-
justify-content: space-around;
2+
display: flex;
3+
flex-direction: row;
4+
align-items: center;
5+
justify-content: space-around;
6+
}
7+
8+
.react-select-container {
9+
font-size: 12px;
10+
min-width: 90px;
11+
margin: 10px;
12+
}
13+
14+
.react-select-container {
15+
.react-select__control,
16+
.react-select__menu {
17+
background-color: $light-grey-one;
618
}
19+
.react-select__single-value {
20+
color: white;
21+
}
22+
.react-select__option:hover {
23+
background-color: #2683ff;
24+
}
25+
.react-select__option--is-selected,
26+
.react-select__option--is-focused {
27+
background-color: transparent;
28+
}
29+
30+
// removes the cursor from blinking
31+
.css-w8afj7-Input {
32+
color: transparent;
33+
}
34+
}

0 commit comments

Comments
 (0)