2016-11-04 13:51:17 +13:00
|
|
|
|
2018-07-28 22:12:36 +12:00
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
|
|
import Icon from '../Icon';
|
|
|
|
|
import * as helpers from '../../helpers';
|
2016-11-04 13:51:17 +13:00
|
|
|
|
2018-03-23 16:54:56 +13:00
|
|
|
export default class VolumeControl extends React.Component{
|
2016-11-04 13:51:17 +13:00
|
|
|
|
2017-10-10 13:05:28 +13:00
|
|
|
constructor(props){
|
2018-07-28 22:12:36 +12:00
|
|
|
super(props);
|
|
|
|
|
|
|
|
|
|
this.handleChange = helpers.throttle(this.handleChange.bind(this), 100);
|
2016-11-04 13:51:17 +13:00
|
|
|
}
|
|
|
|
|
|
2018-07-28 22:12:36 +12:00
|
|
|
handleChange(value){
|
|
|
|
|
this.props.onVolumeChange(value, this.props.volume);
|
2017-08-29 14:35:55 +02:00
|
|
|
}
|
|
|
|
|
|
2016-11-04 13:51:17 +13:00
|
|
|
render(){
|
|
|
|
|
return (
|
2018-10-02 16:58:15 +13:00
|
|
|
<div className={"slider__wrapper "+(this.props.className ? this.props.className : "")}>
|
|
|
|
|
<div className={"slider slider--volume "+(this.props.mute ? "slider--muted" : "")}>
|
|
|
|
|
<input
|
|
|
|
|
className="slider__input"
|
|
|
|
|
type="range"
|
|
|
|
|
min="0"
|
|
|
|
|
max="25"
|
|
|
|
|
value={this.props.volume/4}
|
|
|
|
|
onChange={e => this.handleChange(parseInt(e.target.value)*4)}
|
|
|
|
|
/>
|
|
|
|
|
<div className="slider__track">
|
|
|
|
|
<div className="slider__track__progress" style={{ width: this.props.volume+'%' }}></div>
|
2016-11-04 13:51:17 +13:00
|
|
|
</div>
|
2017-06-22 08:59:40 +12:00
|
|
|
</div>
|
2018-10-02 16:58:15 +13:00
|
|
|
</div>
|
2016-11-04 13:51:17 +13:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|