const bindAll = require('lodash.bindall'); const PropTypes = require('prop-types'); const React = require('react'); const Video = require('../video/video.jsx'); const Spinner = require('../spinner/spinner.jsx'); const classNames = require('classnames'); require('./video-preview.scss'); class VideoPreview extends React.Component { constructor (props) { super(props); bindAll(this, [ 'handleShowVideo', 'handleVideoLoaded' ]); this.state = { videoOpen: false, spinnerVisible: false }; } handleShowVideo () { this.setState({ videoOpen: true, spinnerVisible: true }); } handleVideoLoaded () { this.setState({spinnerVisible: false}); } render () { return (
{this.state.videoOpen ? (
{this.state.spinnerVisible ? : null}
) : (
{this.props.buttonMessage}
) }
); } } VideoPreview.propTypes = { buttonMessage: PropTypes.string.isRequired, thumbnail: PropTypes.string.isRequired, thumbnailHeight: PropTypes.string, thumbnailWidth: PropTypes.string, videoHeight: PropTypes.string, videoId: PropTypes.string.isRequired, videoWidth: PropTypes.string }; module.exports = VideoPreview;