'use client'
import { forwardRef, HTMLAttributes } from 'react'
import { cn } from '@/utils/helpers'
export interface TooltipProps extends HTMLAttributes {
content: string
position?: 'top' | 'bottom' | 'left' | 'right'
children: React.ReactElement
}
export const Tooltip = forwardRef(
({ className, content, position = 'top', children, ...props }, ref) => {
if (!React.isValidElement(children)) {
return <>{children}>
}
const positions = {
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',
}
return (
)
}
)
Tooltip.displayName = 'Tooltip'
// Need to import React
import React from 'react'