2021-08-22 12:05:07 +03:00
|
|
|
import { FC, useRef } from 'react';
|
|
|
|
import * as Popper from 'popper.js';
|
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
|
|
import { faInfoCircle as infoIcon } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { UncontrolledTooltip } from 'reactstrap';
|
|
|
|
|
|
|
|
interface InfoTooltipProps {
|
|
|
|
className?: string;
|
|
|
|
placement: Popper.Placement;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const InfoTooltip: FC<InfoTooltipProps> = ({ className = '', placement, children }) => {
|
2021-08-23 19:26:15 +03:00
|
|
|
const ref = useRef<HTMLSpanElement | null>();
|
|
|
|
const refCallback = (el: HTMLSpanElement) => {
|
|
|
|
ref.current = el;
|
|
|
|
};
|
2021-08-22 12:05:07 +03:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2021-08-23 19:26:15 +03:00
|
|
|
<span className={className} ref={refCallback}>
|
2021-08-22 12:05:07 +03:00
|
|
|
<FontAwesomeIcon icon={infoIcon} />
|
|
|
|
</span>
|
|
|
|
<UncontrolledTooltip target={(() => ref.current) as any} placement={placement}>{children}</UncontrolledTooltip>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|