mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
5731463d32
Tooltip usage refactoring GitOrigin-RevId: f4b2d4d57722172141a081dd60e4394ff7fff332
41 lines
868 B
TypeScript
41 lines
868 B
TypeScript
import {
|
|
OverlayTrigger,
|
|
OverlayTriggerProps,
|
|
Tooltip as BSTooltip,
|
|
} from 'react-bootstrap'
|
|
|
|
type OverlayTriggerCustomProps = {
|
|
shouldUpdatePosition?: boolean // Not officially documented https://stackoverflow.com/a/43138470
|
|
} & OverlayTriggerProps
|
|
|
|
type TooltipProps = {
|
|
children: React.ReactNode
|
|
description: React.ReactNode
|
|
id: string
|
|
overlayProps?: Omit<OverlayTriggerCustomProps, '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
|