1import React, { useState, useCallback } from 'react';
2import { useMemo } from 'react';
4export enum TooltipPosition {
8 // Add more as necessary here and in #positionStyle
11type WithTooltipArgs = {
13 children: React.ReactNode;
14 className?: string | undefined;
15 position?: TooltipPosition;
18export default function WithTooltip({
22 position = TooltipPosition.Top,
24 const [isHovered, setHovered] = useState(false);
25 const onMouseEnter = useCallback(() => setHovered(true), []);
26 const onMouseLeave = useCallback(() => setHovered(false), []);
28 const positionStyle = useMemo(() => {
30 case TooltipPosition.Top:
31 return { bottom: '100%' };
32 case TooltipPosition.TopRight:
33 return { bottom: '90%', left: '90%' };
34 case TooltipPosition.Left:
35 return { bottom: '-67%', left: '-400%' };
37 return { bottom: '100%' };
43 className={className || 'rel nowrap inline-block'}
44 onMouseEnter={onMouseEnter}
45 onMouseLeave={onMouseLeave}>
49 className="abs mb1 bg-black white ph4 pv2 r4 open-tooltip"
50 style={positionStyle}>
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list