Files
jitsi-meet/react/features/toolbox/components/web/Drawer.js
robertpin 601ee219e7 feat(reactions) Added Reactions (#9465)
* Created desktop reactions menu

Moved raise hand functionality to reactions menu

* Added reactions to chat

* Added animations

* Added reactions to the web mobile version

Redesigned the overflow menu. Added the reactions menu and reactions animations

* Make toolbar visible on animation start

* Bug fix

* Cleanup

* Fixed overflow menu desktop

* Revert mobile menu changes

* Removed unused CSS

* Fixed iOS safari issue

* Fixed overflow issue on mobile

* Added keyboard shortcuts for reactions

* Disabled double tap zoom on reaction buttons

* Refactored actions

* Updated option symbol for keyboard shortcuts

* Actions refactor

* Refactor

* Fixed linting errors

* Updated BottomSheet

* Added reactions on native

* Code cleanup

* Code review refactor

* Color fix

* Hide reactions on one participant

* Removed console log

* Lang fix

* Update schortcuts
2021-07-13 09:50:08 +03:00

69 lines
1.5 KiB
JavaScript

// @flow
import React, { useEffect, useRef } from 'react';
type Props = {
/**
* The component(s) to be displayed within the drawer menu.
*/
children: React$Node,
/**
* Whether the drawer should be shown or not.
*/
isOpen: boolean,
/**
* Function that hides the drawer.
*/
onClose: Function
};
/**
* Component that displays the mobile friendly drawer on web.
*
* @returns {ReactElement}
*/
function Drawer({
children,
isOpen,
onClose }: Props) {
const drawerRef: Object = useRef(null);
/**
* Closes the drawer when clicking or touching outside of it.
*
* @param {Event} event - Mouse down/start touch event object.
* @returns {void}
*/
function handleOutsideClickOrTouch(event: Event) {
if (drawerRef.current && !drawerRef.current.contains(event.target)) {
onClose();
}
}
useEffect(() => {
window.addEventListener('mousedown', handleOutsideClickOrTouch);
window.addEventListener('touchstart', handleOutsideClickOrTouch);
return () => {
window.removeEventListener('mousedown', handleOutsideClickOrTouch);
window.removeEventListener('touchstart', handleOutsideClickOrTouch);
};
}, [ drawerRef ]);
return (
isOpen ? (
<div
className = 'drawer-menu'
ref = { drawerRef }>
{children}
</div>
) : null
);
}
export default Drawer;