2021-11-16 14:11:18 +00:00
|
|
|
import ReactTooltip from 'react-tooltip';
|
2022-11-28 02:00:28 +00:00
|
|
|
import { HelpCircle } from 'lucide-react';
|
2022-07-03 23:21:25 +00:00
|
|
|
import clsx from 'clsx';
|
|
|
|
import _ from 'lodash';
|
2021-11-16 14:11:18 +00:00
|
|
|
|
|
|
|
import styles from './Tooltip.module.css';
|
|
|
|
|
2022-07-03 23:21:25 +00:00
|
|
|
type Position = 'top' | 'right' | 'bottom' | 'left';
|
2021-11-16 14:11:18 +00:00
|
|
|
|
|
|
|
export interface Props {
|
2022-07-03 23:21:25 +00:00
|
|
|
position?: Position;
|
2021-11-16 14:11:18 +00:00
|
|
|
message: string;
|
2022-08-24 22:11:25 +00:00
|
|
|
className?: string;
|
2021-11-16 14:11:18 +00:00
|
|
|
}
|
|
|
|
|
2022-08-24 22:11:25 +00:00
|
|
|
export function Tooltip({ message, position = 'bottom', className }: Props) {
|
2022-07-25 01:20:36 +00:00
|
|
|
const id = _.uniqueId('tooltip-');
|
2022-07-03 23:21:25 +00:00
|
|
|
|
2021-11-16 14:11:18 +00:00
|
|
|
return (
|
2022-07-03 23:21:25 +00:00
|
|
|
<span
|
|
|
|
data-tip={message}
|
|
|
|
data-for={id}
|
|
|
|
className={clsx(styles.icon, 'inline-flex text-base')}
|
|
|
|
>
|
2022-11-28 02:00:28 +00:00
|
|
|
<HelpCircle className="lucide" aria-hidden="true" />
|
2021-11-16 14:11:18 +00:00
|
|
|
<ReactTooltip
|
2022-07-03 23:21:25 +00:00
|
|
|
id={id}
|
2021-11-16 14:11:18 +00:00
|
|
|
multiline
|
|
|
|
type="info"
|
|
|
|
place={position}
|
|
|
|
effect="solid"
|
2022-08-24 22:11:25 +00:00
|
|
|
className={clsx(styles.tooltip, className)}
|
2021-11-16 14:11:18 +00:00
|
|
|
arrowColor="transparent"
|
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|