视频播放器仓库

Overlay.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import React, { Component } from 'react';
  2. import styles from './Overlay.css';
  3. import PlayArrow from './../Icon/play_arrow.svg';
  4. import Spin from './../Icon/spin.svg';
  5. import Report from './../Icon/report.svg';
  6. export default class Overlay extends Component {
  7. renderContent () {
  8. const {
  9. error,
  10. paused,
  11. loading
  12. } = this.props;
  13. const iconProps = {
  14. className: styles.icon,
  15. height: 40,
  16. width: 40,
  17. fill: '#fff'
  18. };
  19. if (error) {
  20. return (
  21. <span className={styles.inner}>
  22. <Report {...iconProps} />
  23. </span>
  24. );
  25. } else if (loading) {
  26. return (
  27. <span className={styles.inner}>
  28. <Spin {...iconProps} />
  29. </span>
  30. );
  31. } else if (paused) {
  32. return (
  33. <span className={styles.inner}>
  34. <PlayArrow {...iconProps} />
  35. </span>
  36. );
  37. }
  38. }
  39. render () {
  40. const { className, onClick } = this.props;
  41. return (
  42. <div className={[
  43. styles.component,
  44. className
  45. ].join(' ')}
  46. onClick={onClick}>
  47. { this.renderContent() }
  48. </div>
  49. );
  50. }
  51. }