Extracted InfoTooltip to its own component

This commit is contained in:
Alejandro Celaya
2021-08-22 11:05:07 +02:00
parent e7a969a78d
commit 410d372755
4 changed files with 39 additions and 39 deletions

28
src/utils/InfoTooltip.tsx Normal file
View File

@@ -0,0 +1,28 @@
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 }) => {
const ref = useRef<HTMLElement | null>();
return (
<>
<span
className={className}
ref={(el) => {
ref.current = el;
}}
>
<FontAwesomeIcon icon={infoIcon} />
</span>
<UncontrolledTooltip target={(() => ref.current) as any} placement={placement}>{children}</UncontrolledTooltip>
</>
);
};