Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Tooltip: FC<TooltipProps> = ({
isOpen = defaultProps.isOpen,
fade = defaultProps.fade,
target,
placement = 'top',
...props
}) => {
const [open, setOpen] = useState(isOpen);
Expand All @@ -17,8 +18,26 @@ const Tooltip: FC<TooltipProps> = ({
setOpen(!open);
}, [open]);

//adds offset for the popper placement base on placement prop
const offsets: Record<string, [number, number]> = {
top: [0, 5],
bottom: [0, 5],
left: [0, 8],
right: [0, 8],
};
Comment on lines +22 to +27
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offsets are uneven here to account for the vertical space around text that isn't there horizontally.


const offset = offsets[placement];

return (
<InnerTooltip isOpen={open} toggle={handleToggle} fade={fade} target={target} {...props} />
<InnerTooltip
isOpen={open}
toggle={handleToggle}
fade={fade}
target={target}
placement={placement}
offset={offset}
{...props}
/>
);
};

Expand Down
Loading