2022-04-24 11:39:11 +03:00
|
|
|
import { FC, PropsWithChildren, useRef } from 'react';
|
2021-08-22 12:05:07 +03:00
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
|
|
import { faInfoCircle as infoIcon } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { UncontrolledTooltip } from 'reactstrap';
|
2022-03-11 19:16:24 +03:00
|
|
|
import { Placement } from '@popperjs/core';
|
2022-06-06 21:46:51 +03:00
|
|
|
import { mutableRefToElementRef } from './helpers/components';
|
2021-08-22 12:05:07 +03:00
|
|
|
|
2022-07-08 12:03:58 +03:00
|
|
|
export type InfoTooltipProps = PropsWithChildren<{
|
2021-08-22 12:05:07 +03:00
|
|
|
className?: string;
|
2022-03-11 19:16:24 +03:00
|
|
|
placement: Placement;
|
2022-04-24 11:39:11 +03:00
|
|
|
}>;
|
2021-08-22 12:05:07 +03:00
|
|
|
|
|
|
|
export const InfoTooltip: FC<InfoTooltipProps> = ({ className = '', placement, children }) => {
|
2022-06-06 21:46:51 +03:00
|
|
|
const ref = useRef<HTMLSpanElement | undefined>();
|
2021-08-22 12:05:07 +03:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2022-06-06 21:46:51 +03:00
|
|
|
<span className={className} ref={mutableRefToElementRef(ref)}>
|
2021-08-22 12:05:07 +03:00
|
|
|
<FontAwesomeIcon icon={infoIcon} />
|
|
|
|
</span>
|
|
|
|
<UncontrolledTooltip target={(() => ref.current) as any} placement={placement}>{children}</UncontrolledTooltip>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|