mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-09 17:57:26 +03:00
26 lines
873 B
TypeScript
26 lines
873 B
TypeScript
import { FC, PropsWithChildren, useRef } from 'react';
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
import { faInfoCircle as infoIcon } from '@fortawesome/free-solid-svg-icons';
|
|
import { UncontrolledTooltip } from 'reactstrap';
|
|
import { Placement } from '@popperjs/core';
|
|
|
|
type InfoTooltipProps = PropsWithChildren<{
|
|
className?: string;
|
|
placement: Placement;
|
|
}>;
|
|
|
|
export const InfoTooltip: FC<InfoTooltipProps> = ({ className = '', placement, children }) => {
|
|
const ref = useRef<HTMLSpanElement | null>();
|
|
const refCallback = (el: HTMLSpanElement) => {
|
|
ref.current = el;
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<span className={className} ref={refCallback}>
|
|
<FontAwesomeIcon icon={infoIcon} />
|
|
</span>
|
|
<UncontrolledTooltip target={(() => ref.current) as any} placement={placement}>{children}</UncontrolledTooltip>
|
|
</>
|
|
);
|
|
};
|