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.

ReactionsMenuPopup.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // @flow
  2. import InlineDialog from '@atlaskit/inline-dialog';
  3. import React from 'react';
  4. import { useDispatch, useSelector } from 'react-redux';
  5. import { toggleReactionsMenuVisibility } from '../../actions.web';
  6. import { getReactionsMenuVisibility } from '../../functions.web';
  7. import ReactionsMenu from './ReactionsMenu';
  8. type Props = {
  9. /**
  10. * Component's children (the reactions menu button).
  11. */
  12. children: React$Node
  13. }
  14. /**
  15. * Popup with reactions menu.
  16. *
  17. * @returns {ReactElement}
  18. */
  19. function ReactionsMenuPopup({
  20. children
  21. }: Props) {
  22. /**
  23. * Flag controlling the visibility of the popup.
  24. */
  25. const isOpen = useSelector(state => getReactionsMenuVisibility(state));
  26. const dispatch = useDispatch();
  27. /**
  28. * Toggles reactions menu visibility.
  29. *
  30. * @returns {void}
  31. */
  32. function onClose() {
  33. dispatch(toggleReactionsMenuVisibility());
  34. }
  35. return (
  36. <div className = 'reactions-menu-popup'>
  37. <InlineDialog
  38. content = { <ReactionsMenu /> }
  39. isOpen = { isOpen }
  40. onClose = { onClose }
  41. placement = 'top'>
  42. {children}
  43. </InlineDialog>
  44. </div>
  45. );
  46. }
  47. export default ReactionsMenuPopup;