2017-06-04 10:40:14 +08:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2018-04-10 02:28:54 +08:00
|
|
|
import cx from 'classnames';
|
2018-04-18 01:55:07 +08:00
|
|
|
import VideoProviderContainer from '/imports/ui/components/video-provider/container';
|
|
|
|
|
2018-01-08 14:17:18 +08:00
|
|
|
import { styles } from './styles';
|
2016-05-04 04:40:46 +08:00
|
|
|
|
|
|
|
const propTypes = {
|
2018-04-12 02:50:14 +08:00
|
|
|
children: PropTypes.element.isRequired,
|
2018-04-10 02:28:54 +08:00
|
|
|
floatingOverlay: PropTypes.bool,
|
|
|
|
hideOverlay: PropTypes.bool,
|
2016-05-04 04:40:46 +08:00
|
|
|
};
|
2016-05-03 06:42:54 +08:00
|
|
|
|
2017-10-11 06:08:51 +08:00
|
|
|
const defaultProps = {
|
2018-04-10 02:28:54 +08:00
|
|
|
floatingOverlay: false,
|
|
|
|
hideOverlay: true,
|
2017-10-11 06:08:51 +08:00
|
|
|
};
|
|
|
|
|
2018-04-27 23:11:40 +08:00
|
|
|
|
2016-05-03 06:42:54 +08:00
|
|
|
export default class Media extends Component {
|
2018-04-12 02:50:14 +08:00
|
|
|
componentWillUpdate() {
|
|
|
|
window.dispatchEvent(new Event('resize'));
|
2016-05-04 04:40:46 +08:00
|
|
|
}
|
|
|
|
|
2018-04-12 02:50:14 +08:00
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
swapLayout, floatingOverlay, hideOverlay, disableVideo,
|
|
|
|
} = this.props;
|
2018-04-10 02:28:54 +08:00
|
|
|
|
2018-04-12 02:50:14 +08:00
|
|
|
const contentClassName = cx({
|
|
|
|
[styles.content]: true,
|
|
|
|
});
|
2016-05-04 04:40:46 +08:00
|
|
|
|
2018-04-12 02:50:14 +08:00
|
|
|
const overlayClassName = cx({
|
|
|
|
[styles.overlay]: true,
|
|
|
|
[styles.hideOverlay]: hideOverlay,
|
|
|
|
[styles.floatingOverlay]: floatingOverlay,
|
|
|
|
});
|
2016-05-04 04:40:46 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles.container}>
|
2018-04-12 02:50:14 +08:00
|
|
|
<div className={!swapLayout ? contentClassName : overlayClassName}>
|
|
|
|
{this.props.children}
|
|
|
|
</div>
|
|
|
|
<div className={!swapLayout ? overlayClassName : contentClassName}>
|
|
|
|
{ !disableVideo ? <VideoProviderContainer /> : null }
|
|
|
|
</div>
|
2016-05-03 06:42:54 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2016-05-04 04:40:46 +08:00
|
|
|
|
|
|
|
Media.propTypes = propTypes;
|
2017-10-11 06:08:51 +08:00
|
|
|
Media.defaultProps = defaultProps;
|