mirror of https://github.com/morpheus65535/bazarr
31 lines
726 B
TypeScript
31 lines
726 B
TypeScript
import { Tooltip, TooltipProps } from "@mantine/core";
|
|
import { useHover } from "@mantine/hooks";
|
|
import { isNull, isUndefined } from "lodash";
|
|
import { FunctionComponent, ReactElement } from "react";
|
|
|
|
interface TextPopoverProps {
|
|
children: ReactElement;
|
|
text: string | undefined | null;
|
|
tooltip?: Omit<TooltipProps, "opened" | "label" | "children">;
|
|
}
|
|
|
|
const TextPopover: FunctionComponent<TextPopoverProps> = ({
|
|
children,
|
|
text,
|
|
tooltip,
|
|
}) => {
|
|
const { hovered, ref } = useHover();
|
|
|
|
if (isNull(text) || isUndefined(text)) {
|
|
return children;
|
|
}
|
|
|
|
return (
|
|
<Tooltip opened={hovered} label={text} {...tooltip}>
|
|
<div ref={ref}>{children}</div>
|
|
</Tooltip>
|
|
);
|
|
};
|
|
|
|
export default TextPopover;
|