import React, { HTMLAttributes, ReactNode } from 'react'
import Tippy, { TippyProps } from '@tippyjs/react'
import 'tippy.js/animations/scale.css'
import { ttCommons, ttCommonsExpanded, ttCommonsMono } from 'utils/fonts'
type TooltipProps = {
content: ReactNode
placement?: TippyProps['placement']
className?: string
children?: ReactNode
delay?: number
show?: boolean
maxWidth?: string
}
const Tooltip = ({
children,
content,
className,
placement = 'top',
delay = 0,
show = true,
maxWidth = '20rem',
}: TooltipProps) => {
if (show) {
return (
document.body}
maxWidth={maxWidth}
interactive
delay={[delay, 0]}
content={
content ? (
{content}
) : null
}
>
{children}
)
} else {
return <>{children}>
}
}
const Content = ({
className,
children,
}: {
className?: string
} & HTMLAttributes) => {
return (
{children}
)
}
Tooltip.Content = Content
export default Tooltip