1import React, { useState, useCallback } from 'react';
2import { useMemo } from 'react';
4export enum TooltipPosition {
7 // Add more as necessary here and in #positionStyle
10type WithTooltipArgs = {
12 children: React.ReactNode;
13 className?: string | undefined;
14 position?: TooltipPosition;
17export 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 open-tooltip"
47 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