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
|
|
|
}
|
|
|
|
|
|
2017-06-18 05:47:36 +12:00
|
|
|
renderMuteButton(){
|
|
|
|
|
if (this.props.mute){
|
|
|
|
|
return (
|
2018-09-21 11:58:54 +12:00
|
|
|
<a className="control mute-control tooltip" onClick={() => this.props.onMuteChange(false)}>
|
2018-05-16 21:08:45 +12:00
|
|
|
<Icon className="red-text" name="volume_off" />
|
2018-09-21 11:58:54 +12:00
|
|
|
<span className="tooltip__content">Unmute</span>
|
2017-06-18 05:47:36 +12:00
|
|
|
</a>
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
return (
|
2018-09-21 11:58:54 +12:00
|
|
|
<a className="control mute-control tooltip" onClick={() => this.props.onMuteChange(true)}>
|
2018-05-16 21:08:45 +12:00
|
|
|
<Icon className="muted" name="volume_mute" />
|
2018-09-21 11:58:54 +12:00
|
|
|
<span className="tooltip__content">Mute</span>
|
2017-06-18 05:47:36 +12:00
|
|
|
</a>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-04 13:51:17 +13:00
|
|
|
render(){
|
2018-05-02 16:14:53 +12:00
|
|
|
var className = "volume-control";
|
2017-06-18 05:47:36 +12:00
|
|
|
if (this.props.mute){
|
2018-05-02 16:14:53 +12:00
|
|
|
className += " muted";
|
2017-06-18 05:47:36 +12:00
|
|
|
}
|
2018-05-02 16:14:53 +12:00
|
|
|
if (this.props.className){
|
|
|
|
|
className += " "+this.props.className;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-04 13:51:17 +13:00
|
|
|
return (
|
2018-07-28 22:12:36 +12:00
|
|
|
<span className={className}>
|
2018-05-30 21:39:38 +12:00
|
|
|
{this.props.NoMuteButton ? null : this.renderMuteButton()}
|
2017-06-22 08:59:40 +12:00
|
|
|
<div className="slider-wrapper">
|
2018-08-27 08:21:41 +12:00
|
|
|
<div className={"slider horizontal"+(this.props.mute ? " disabled" : "")}>
|
2018-07-28 22:12:36 +12:00
|
|
|
<input
|
|
|
|
|
type="range"
|
|
|
|
|
min="0"
|
|
|
|
|
max="25"
|
|
|
|
|
value={this.props.volume/4}
|
|
|
|
|
onChange={e => this.handleChange(parseInt(e.target.value)*4)}
|
|
|
|
|
/>
|
2017-06-22 08:59:40 +12:00
|
|
|
<div className="track">
|
|
|
|
|
<div className="progress" style={{ width: this.props.volume+'%' }}></div>
|
2016-11-04 13:51:17 +13:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2017-06-22 08:59:40 +12:00
|
|
|
</div>
|
2016-11-04 13:51:17 +13:00
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|