mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-28 23:04:08 +00:00
33 lines
1,014 B
JavaScript
33 lines
1,014 B
JavaScript
const React = require('react');
|
|
const PropTypes = require('prop-types');
|
|
const classnames = require('classnames');
|
|
const Icon = require('stremio-icons/dom');
|
|
|
|
class PlayPauseButton extends React.Component {
|
|
shouldComponentUpdate(nextProps, nextState) {
|
|
return nextProps.className !== this.props.className ||
|
|
nextProps.paused !== this.props.paused;
|
|
}
|
|
|
|
togglePaused = () => {
|
|
this.props.dispatch('setProp', 'paused', !this.props.paused);
|
|
}
|
|
|
|
render() {
|
|
const disabled = this.props.paused === null;
|
|
const icon = this.props.paused ? 'ic_play' : 'ic_pause';
|
|
return (
|
|
<div className={classnames(this.props.className, { 'disabled': disabled })} onClick={this.togglePaused}>
|
|
<Icon className={'icon'} icon={icon} />
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
PlayPauseButton.propTypes = {
|
|
className: PropTypes.string,
|
|
paused: PropTypes.bool,
|
|
dispatch: PropTypes.func.isRequired
|
|
};
|
|
|
|
module.exports = PlayPauseButton;
|