import {flip, offset, shift, useFloating} from '@floating-ui/react-dom' import {QuestionMarkCircleIcon} from '@heroicons/react/24/outline' import {useState} from 'react' export function QuestionMarkTooltip(props: {text: string | any}) { // Work like Tooltip but also gets triggered upon click and not just highlight (which is necessary for mobile) // Use QuestionMarkTooltip for question marks (no click, no button) // Use Tooltip for buttons (star, message, etc.) // Seems like tooltip without noTap works const {text} = props const [open, setOpen] = useState(false) const {y, refs, strategy} = useFloating({ placement: 'bottom', // place below the trigger middleware: [ offset(8), // small gap between ? and box flip(), shift({padding: 8}), // prevent viewport clipping ], }) return ( <> setOpen(true)} onMouseLeave={() => setOpen(false)} ref={refs.setReference} > {open && (

{text}

)} ) }