| 1 | import { CSSProperties } from "react"; |
| 2 | import ReactDOM from "react-dom"; |
| 3 | import { ITooltip, Tooltip } from "react-tooltip"; |
| 4 | import { vscBackground, vscForeground, vscInputBorder } from ".."; |
| 5 | import { fontSize } from "../../util"; |
| 6 | |
| 7 | const TooltipStyles: CSSProperties = { |
| 8 | fontSize: fontSize(-2), |
| 9 | backgroundColor: vscBackground, |
| 10 | outline: `0.5px solid ${vscInputBorder}`, |
| 11 | color: vscForeground, |
| 12 | padding: "4px 8px", |
| 13 | zIndex: 1000, |
| 14 | maxWidth: "80vw", |
| 15 | textAlign: "center", |
| 16 | }; |
| 17 | |
| 18 | export function ToolTip(props: ITooltip) { |
| 19 | const combinedStyles = { |
| 20 | ...TooltipStyles, |
| 21 | ...props.style, |
| 22 | }; |
| 23 | |
| 24 | const tooltipPortalDiv = document.getElementById("tooltip-portal-div"); |
| 25 | |
| 26 | return ( |
| 27 | tooltipPortalDiv && |
| 28 | ReactDOM.createPortal( |
| 29 | <Tooltip {...props} style={combinedStyles} opacity={1} delayShow={200} />, |
| 30 | tooltipPortalDiv, |
| 31 | ) |
| 32 | ); |
| 33 | } |