2021-04-16 11:55:48 -07:00
|
|
|
import React, { FunctionComponent, ReactNode } from 'react'
|
2021-04-16 11:16:31 -07:00
|
|
|
import Tippy from '@tippyjs/react'
|
|
|
|
import 'tippy.js/animations/scale.css'
|
|
|
|
|
|
|
|
type TooltipProps = {
|
|
|
|
content: ReactNode
|
2021-04-24 15:02:13 -07:00
|
|
|
className?: string
|
2021-04-16 11:16:31 -07:00
|
|
|
}
|
|
|
|
|
2021-04-24 15:02:13 -07:00
|
|
|
const Tooltip: FunctionComponent<TooltipProps> = ({
|
|
|
|
children,
|
|
|
|
content,
|
|
|
|
className,
|
|
|
|
}) => {
|
2021-04-16 11:16:31 -07:00
|
|
|
return (
|
|
|
|
<Tippy
|
|
|
|
animation="scale"
|
2021-04-16 12:07:59 -07:00
|
|
|
appendTo={() => document.body}
|
2021-05-01 07:02:21 -07:00
|
|
|
maxWidth="20rem"
|
2021-04-16 11:16:31 -07:00
|
|
|
interactive
|
|
|
|
content={
|
2021-04-24 15:02:13 -07:00
|
|
|
<div
|
2021-05-01 07:02:21 -07:00
|
|
|
className={`rounded p-3 text-xs bg-th-bkg-3 leading-5 shadow-md text-th-fgd-3 outline-none focus:outline-none ${className}`}
|
2021-04-24 15:02:13 -07:00
|
|
|
>
|
2021-04-16 11:16:31 -07:00
|
|
|
{content}
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
>
|
2021-04-25 10:08:11 -07:00
|
|
|
<div className="outline-none focus:outline-none">{children}</div>
|
2021-04-16 11:16:31 -07:00
|
|
|
</Tippy>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Tooltip
|