You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bazarr/frontend/src/components/TextPopover.tsx

31 lines
726 B

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;