overleaf/services/web/frontend/js/shared/components/tooltip.tsx

38 lines
694 B
TypeScript
Raw Normal View History

import {
OverlayTrigger,
OverlayTriggerProps,
Tooltip as BSTooltip,
} from 'react-bootstrap'
type TooltipProps = {
children: React.ReactNode
description: string
id: string
overlayProps?: Omit<OverlayTriggerProps, 'overlay'>
tooltipProps?: BSTooltip.TooltipProps
}
function Tooltip({
id,
description,
children,
tooltipProps,
overlayProps,
}: TooltipProps) {
return (
<OverlayTrigger
overlay={
<BSTooltip id={`${id}-tooltip`} {...tooltipProps}>
{description}
</BSTooltip>
}
{...overlayProps}
placement={overlayProps?.placement || 'top'}
>
{children}
</OverlayTrigger>
)
}
export default Tooltip