You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FilmstripOnlyOverlayFrame.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. import PropTypes from 'prop-types';
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import {
  5. Avatar,
  6. getAvatarURL,
  7. getLocalParticipant
  8. } from '../../base/participants';
  9. import OverlayFrame from './OverlayFrame';
  10. /**
  11. * Implements a React Component for the frame of the overlays in filmstrip only
  12. * mode.
  13. */
  14. class FilmstripOnlyOverlayFrame extends Component {
  15. /**
  16. * FilmstripOnlyOverlayFrame component's property types.
  17. *
  18. * @static
  19. */
  20. static propTypes = {
  21. /**
  22. * The source (e.g. URI, URL) of the avatar image of the local
  23. * participant.
  24. *
  25. * @private
  26. */
  27. _avatar: PropTypes.string,
  28. /**
  29. * The children components to be displayed into the overlay frame for
  30. * filmstrip only mode.
  31. *
  32. * @type {ReactElement}
  33. */
  34. children: PropTypes.node.isRequired,
  35. /**
  36. * The css class name for the icon that will be displayed over the
  37. * avatar.
  38. *
  39. * @type {string}
  40. */
  41. icon: PropTypes.string,
  42. /**
  43. * Indicates the css style of the overlay. If true, then lighter;
  44. * darker, otherwise.
  45. *
  46. * @type {boolean}
  47. */
  48. isLightOverlay: PropTypes.bool
  49. };
  50. /**
  51. * Renders content related to the icon.
  52. *
  53. * @returns {ReactElement|null}
  54. * @private
  55. */
  56. _renderIcon() {
  57. if (!this.props.icon) {
  58. return null;
  59. }
  60. const iconClass = `inlay-filmstrip-only__icon ${this.props.icon}`;
  61. const iconBGClass = 'inlay-filmstrip-only__icon-background';
  62. return (
  63. <div>
  64. <div className = { iconBGClass } />
  65. <div className = 'inlay-filmstrip-only__icon-container'>
  66. <span className = { iconClass } />
  67. </div>
  68. </div>
  69. );
  70. }
  71. /**
  72. * Implements React's {@link Component#render()}.
  73. *
  74. * @inheritdoc
  75. * @returns {ReactElement|null}
  76. */
  77. render() {
  78. return (
  79. <OverlayFrame isLightOverlay = { this.props.isLightOverlay }>
  80. <div className = 'inlay-filmstrip-only'>
  81. <div className = 'inlay-filmstrip-only__content'>
  82. {
  83. this.props.children
  84. }
  85. </div>
  86. <div className = 'inlay-filmstrip-only__avatar-container'>
  87. <Avatar uri = { this.props._avatar } />
  88. {
  89. this._renderIcon()
  90. }
  91. </div>
  92. </div>
  93. </OverlayFrame>
  94. );
  95. }
  96. }
  97. /**
  98. * Maps (parts of) the Redux state to the associated FilmstripOnlyOverlayFrame
  99. * props.
  100. *
  101. * @param {Object} state - The Redux state.
  102. * @private
  103. * @returns {{
  104. * _avatar: string
  105. * }}
  106. */
  107. function _mapStateToProps(state) {
  108. return {
  109. _avatar: getAvatarURL(getLocalParticipant(state) || {})
  110. };
  111. }
  112. export default connect(_mapStateToProps)(FilmstripOnlyOverlayFrame);