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 2.8KB

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