import classNames from 'classnames'; import React, { useState, useRef } from 'react'; import { usePopper } from 'react-popper'; interface IHoverable { component: JSX.Element, } /** Wrapper to render a given component when hovered */ const Hoverable: React.FC = ({ component, children, }): JSX.Element => { const [portalActive, setPortalActive] = useState(false); const ref = useRef(null); const popperRef = useRef(null); const handleMouseEnter = () => { setPortalActive(true); }; const handleMouseLeave = () => { setPortalActive(false); }; const { styles, attributes } = usePopper(ref.current, popperRef.current, { placement: 'top-start', strategy: 'fixed', modifiers: [ { name: 'offset', options: { offset: [-10, 0], }, }, ], }); return (
{children}
{component}
); }; export default Hoverable;