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 transform -translate-x-1/2 mb-2', bottom: 'top-full left-1/2 transform -translate-x-1/2 mt-2', left: 'right-full top-1/2 transform -translate-y-1/2 mr-2', right: 'left-full top-1/2 transform -translate-y-1/2 ml-2' }; const arrowClasses = { top: 'top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100', bottom: 'bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100', left: 'left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100', right: 'right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100' }; return (
setIsVisible(true)} onMouseLeave={() => setIsVisible(false)} > {children} {isVisible && (
{content}
)}
); }; export default Tooltip;