@@ -0,0 +1,53 @@
1+import React, { useState, useCallback } from 'react';
2+import { useMemo } from 'react';
4+export enum TooltipPosition {
7+ // Add more as necessary here and in #positionStyle
10+type WithTooltipArgs = {
12+ children: React.ReactNode;
13+ className?: string | undefined;
14+ position?: TooltipPosition;
17+export default function WithTooltip({
21+ position = TooltipPosition.Top,
23+ const [isHovered, setHovered] = useState(false);
24+ const onMouseEnter = useCallback(() => setHovered(true), []);
25+ const onMouseLeave = useCallback(() => setHovered(false), []);
27+ const positionStyle = useMemo(() => {
29+ case TooltipPosition.Top:
30+ return { bottom: '100%' };
31+ case TooltipPosition.TopRight:
32+ return { bottom: '90%', left: '90%' };
34+ return { bottom: '100%' };
40+ className={className || 'rel nowrap inline-block'}
41+ onMouseEnter={onMouseEnter}
42+ onMouseLeave={onMouseLeave}>
46+ className="abs mb1 bg-black white ph4 pv2 r4"
47+ style={positionStyle}>