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.

ReactionsMenuButton.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // @flow
  2. import React from 'react';
  3. import { translate } from '../../../base/i18n';
  4. import { IconRaisedHand } from '../../../base/icons';
  5. import { getLocalParticipant } from '../../../base/participants';
  6. import { connect } from '../../../base/redux';
  7. import ToolbarButton from '../../../toolbox/components/web/ToolbarButton';
  8. import { toggleReactionsMenuVisibility } from '../../actions.web';
  9. import { type ReactionEmojiProps } from '../../constants';
  10. import { getReactionsQueue } from '../../functions.any';
  11. import { getReactionsMenuVisibility } from '../../functions.web';
  12. import ReactionEmoji from './ReactionEmoji';
  13. import ReactionsMenuPopup from './ReactionsMenuPopup';
  14. type Props = {
  15. /**
  16. * Used for translation.
  17. */
  18. t: Function,
  19. /**
  20. * Whether or not the local participant's hand is raised.
  21. */
  22. raisedHand: boolean,
  23. /**
  24. * Click handler for the reaction button. Toggles the reactions menu.
  25. */
  26. onReactionsClick: Function,
  27. /**
  28. * Whether or not the reactions menu is open.
  29. */
  30. isOpen: boolean,
  31. /**
  32. * The array of reactions to be displayed.
  33. */
  34. reactionsQueue: Array<ReactionEmojiProps>,
  35. /**
  36. * Redux dispatch function.
  37. */
  38. dispatch: Function
  39. };
  40. declare var APP: Object;
  41. /**
  42. * Button used for the reactions menu.
  43. *
  44. * @returns {ReactElement}
  45. */
  46. function ReactionsMenuButton({
  47. t,
  48. raisedHand,
  49. isOpen,
  50. reactionsQueue,
  51. dispatch
  52. }: Props) {
  53. /**
  54. * Toggles the reactions menu visibility.
  55. *
  56. * @returns {void}
  57. */
  58. function toggleReactionsMenu() {
  59. dispatch(toggleReactionsMenuVisibility());
  60. }
  61. return (
  62. <div className = 'reactions-menu-popup-container'>
  63. <ReactionsMenuPopup>
  64. <ToolbarButton
  65. accessibilityLabel = { t('toolbar.accessibilityLabel.reactionsMenu') }
  66. icon = { IconRaisedHand }
  67. key = 'reactions'
  68. onClick = { toggleReactionsMenu }
  69. toggled = { raisedHand }
  70. tooltip = { t(`toolbar.${isOpen ? 'closeReactionsMenu' : 'openReactionsMenu'}`) } />
  71. </ReactionsMenuPopup>
  72. {reactionsQueue.map(({ reaction, uid }, index) => (<ReactionEmoji
  73. index = { index }
  74. key = { uid }
  75. reaction = { reaction }
  76. uid = { uid } />))}
  77. </div>
  78. );
  79. }
  80. /**
  81. * Function that maps parts of Redux state tree into component props.
  82. *
  83. * @param {Object} state - Redux state.
  84. * @returns {Object}
  85. */
  86. function mapStateToProps(state) {
  87. const localParticipant = getLocalParticipant(state);
  88. return {
  89. isOpen: getReactionsMenuVisibility(state),
  90. reactionsQueue: getReactionsQueue(state),
  91. raisedHand: localParticipant?.raisedHand
  92. };
  93. }
  94. export default translate(connect(mapStateToProps)(ReactionsMenuButton));