Files
shlink-web-client/src/utils/InfoTooltip.tsx
2023-02-18 10:40:37 +01:00

25 lines
824 B
TypeScript

import type { FC, PropsWithChildren } from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faInfoCircle as infoIcon } from '@fortawesome/free-solid-svg-icons';
import { UncontrolledTooltip } from 'reactstrap';
import type { Placement } from '@popperjs/core';
import { useElementRef } from './helpers/hooks';
export type InfoTooltipProps = PropsWithChildren<{
className?: string;
placement: Placement;
}>;
export const InfoTooltip: FC<InfoTooltipProps> = ({ className = '', placement, children }) => {
const ref = useElementRef<HTMLSpanElement>();
return (
<>
<span className={className} ref={ref}>
<FontAwesomeIcon icon={infoIcon} />
</span>
<UncontrolledTooltip target={ref} placement={placement}>{children}</UncontrolledTooltip>
</>
);
};