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.4KB

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