made EmojiBoard reusable

This commit is contained in:
unknown 2021-08-14 10:19:29 +05:30
parent 769fd7b524
commit 0404f30c87
7 changed files with 118 additions and 8 deletions

View file

@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import './ContextMenu.scss';
@ -10,12 +10,16 @@ import Button from '../button/Button';
import ScrollView from '../scroll/ScrollView';
function ContextMenu({
content, placement, maxWidth, render,
content, placement, maxWidth, render, afterToggle,
}) {
const [isVisible, setVisibility] = useState(false);
const showMenu = () => setVisibility(true);
const hideMenu = () => setVisibility(false);
useEffect(() => {
if (afterToggle !== null) afterToggle(isVisible);
}, [isVisible]);
return (
<Tippy
animation="scale-extreme"
@ -36,6 +40,7 @@ function ContextMenu({
ContextMenu.defaultProps = {
maxWidth: 'unset',
placement: 'right',
afterToggle: null,
};
ContextMenu.propTypes = {
@ -49,6 +54,7 @@ ContextMenu.propTypes = {
PropTypes.number,
]),
render: PropTypes.func.isRequired,
afterToggle: PropTypes.func,
};
function MenuHeader({ children }) {