import React from "react"; /** * Hover tooltip. Wraps a trigger; shows a small dark label. */ export function Tooltip({ label, placement = "top", children, style = {} }) { const [show, setShow] = React.useState(false); const pos = { top: { bottom: "calc(100% + 7px)", left: "50%", transform: "translateX(-50%)" }, bottom: { top: "calc(100% + 7px)", left: "50%", transform: "translateX(-50%)" }, left: { right: "calc(100% + 7px)", top: "50%", transform: "translateY(-50%)" }, right: { left: "calc(100% + 7px)", top: "50%", transform: "translateY(-50%)" }, }[placement]; return ( setShow(true)} onMouseLeave={() => setShow(false)} style={{ position: "relative", display: "inline-flex", ...style }} > {children} {show && label && ( {label} )} ); }