Files
Iris/src/js/components/Fields/VolumeControl.js

67 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-11-04 13:51:17 +13: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){
super(props);
this.handleChange = helpers.throttle(this.handleChange.bind(this), 100);
2016-11-04 13:51:17 +13:00
}
handleChange(value){
this.props.onVolumeChange(value, this.props.volume);
}
2017-06-18 05:47:36 +12:00
renderMuteButton(){
if (this.props.mute){
return (
2018-03-23 16:54:56 +13:00
<a className="control mute-control has-tooltip" onClick={() => this.props.onMuteChange(false)}>
2018-05-16 21:08:45 +12:00
<Icon className="red-text" name="volume_off" />
2017-06-18 05:47:36 +12:00
<span className="tooltip">Unmute</span>
</a>
)
} else {
return (
2018-03-23 16:54:56 +13:00
<a className="control mute-control has-tooltip" onClick={() => this.props.onMuteChange(true)}>
2018-05-16 21:08:45 +12:00
<Icon className="muted" name="volume_mute" />
2017-06-18 05:47:36 +12:00
<span className="tooltip">Mute</span>
</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 (
<span className={className}>
{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" : "")}>
<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>
);
}
}