import React, { useState } from 'react'; interface TooltipProps { content: string; children: React.ReactNode; position?: 'top' | 'bottom' | 'left' | 'right'; } const Tooltip: React.FC = ({ content, children, position = 'top' }) => { const [isVisible, setIsVisible] = useState(false); const positionClasses = { top: 'bottom-full left-1/2 -translate-x-1/2 mb-2', bottom: 'top-full left-1/2 -translate-x-1/2 mt-2', left: 'right-full top-1/2 -translate-y-1/2 mr-2', right: 'left-full top-1/2 -translate-y-1/2 ml-2', }; const arrowClasses = { top: 'top-full left-1/2 -translate-x-1/2 border-t-slate-800', bottom: 'bottom-full left-1/2 -translate-x-1/2 border-b-slate-800', left: 'left-full top-1/2 -translate-y-1/2 border-l-slate-800', right: 'right-full top-1/2 -translate-y-1/2 border-r-slate-800', }; return (
setIsVisible(true)} onMouseLeave={() => setIsVisible(false)} onFocus={() => setIsVisible(true)} onBlur={() => setIsVisible(false)} > {children} {isVisible && (
{content}
)}
); }; export default React.memo(Tooltip);