Elffuss BraidHub

kikocis/continue public

c3f798ae5f86 · 1.5 KiBRawPermalink
1import React from "react";
2import { type PlacesType } from "react-tooltip";
3import { v4 as uuidv4 } from "uuid";
4import { HeaderButton } from "..";
5import { ToolTip } from "./Tooltip";
6
7interface HeaderButtonWithToolTipProps {
8 text: string | undefined;
9 onClick?: (e: any) => void;
10 children: React.ReactNode;
11 disabled?: boolean;
12 inverted?: boolean;
13 active?: boolean;
14 className?: string;
15 onKeyDown?: (e: any) => void;
16 tabIndex?: number;
17 style?: React.CSSProperties;
18 backgroundColor?: string;
19 hoverBackgroundColor?: string;
20 tooltipPlacement?: PlacesType;
21 testId?: string;
22}
23
24const HeaderButtonWithToolTip = React.forwardRef<
25 HTMLButtonElement,
26 HeaderButtonWithToolTipProps
27>((props: HeaderButtonWithToolTipProps, ref) => {
28 const id = uuidv4();
29 const tooltipId = `header_button_${id}`;
30
31 return (
32 <>
33 <HeaderButton
34 hoverBackgroundColor={props.hoverBackgroundColor}
35 backgroundColor={props.backgroundColor}
36 data-tooltip-id={tooltipId}
37 data-testid={props.testId}
38 inverted={props.inverted}
39 disabled={props.disabled}
40 onClick={props.onClick}
41 onKeyDown={props.onKeyDown}
42 className={props.className}
43 style={props.style}
44 ref={ref}
45 tabIndex={props.tabIndex}
46 >
47 {props.children}
48 </HeaderButton>
49
50 <ToolTip id={tooltipId} place={props.tooltipPlacement ?? "bottom"}>
51 <span className="text-xs">{props.text}</span>
52 </ToolTip>
53 </>
54 );
55});
56
57export default HeaderButtonWithToolTip;