feat: tooltip foundation (#2950)
* feat: add foundation for tooltips * fix: add lang * refactor: remove React import where no longer necessarypull/2951/head
parent
36d17fed6e
commit
16545eec22
@ -0,0 +1,36 @@
|
||||
import { usePopperTooltip } from 'react-popper-tooltip';
|
||||
import type { Config } from 'react-popper-tooltip';
|
||||
|
||||
type TooltipProps = {
|
||||
content: React.ReactNode;
|
||||
children: React.ReactNode;
|
||||
tooltipConfig?: Config;
|
||||
};
|
||||
|
||||
const Tooltip = ({ children, content, tooltipConfig }: TooltipProps) => {
|
||||
const { getTooltipProps, setTooltipRef, setTriggerRef, visible } =
|
||||
usePopperTooltip({
|
||||
followCursor: true,
|
||||
placement: 'left-end',
|
||||
...tooltipConfig,
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<div ref={setTriggerRef}>{children}</div>
|
||||
{visible && (
|
||||
<div
|
||||
ref={setTooltipRef}
|
||||
{...getTooltipProps({
|
||||
className:
|
||||
'bg-gray-800 px-2 py-1 rounded border border-gray-600 shadow text-gray-100',
|
||||
})}
|
||||
>
|
||||
{content}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Tooltip;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue