2024-09-12 14:47:46 +03:00
|
|
|
import clsx from 'clsx';
|
|
|
|
|
|
|
|
import { globals } from '@/utils/constants';
|
|
|
|
|
|
|
|
import { CProps } from '../props';
|
|
|
|
|
|
|
|
interface IndicatorProps extends CProps.Titled, CProps.Styling {
|
2024-09-12 16:41:48 +03:00
|
|
|
/** Icon to display. */
|
2024-09-12 14:47:46 +03:00
|
|
|
icon: React.ReactNode;
|
2024-09-12 16:41:48 +03:00
|
|
|
|
|
|
|
/** Indicates whether the indicator should have no padding. */
|
2024-09-12 14:47:46 +03:00
|
|
|
noPadding?: boolean;
|
|
|
|
}
|
|
|
|
|
2024-09-12 16:41:48 +03:00
|
|
|
/**
|
|
|
|
* Indicator component that displays a status `icon` with a tooltip.
|
|
|
|
*/
|
2024-09-12 14:47:46 +03:00
|
|
|
function Indicator({ icon, title, titleHtml, hideTitle, noPadding, className, ...restProps }: IndicatorProps) {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className={clsx(
|
|
|
|
'clr-btn-clear',
|
|
|
|
'outline-none',
|
|
|
|
{
|
|
|
|
'px-1 py-1': !noPadding
|
|
|
|
},
|
|
|
|
className
|
|
|
|
)}
|
|
|
|
data-tooltip-id={!!title || !!titleHtml ? globals.tooltip : undefined}
|
|
|
|
data-tooltip-html={titleHtml}
|
|
|
|
data-tooltip-content={title}
|
|
|
|
data-tooltip-hidden={hideTitle}
|
|
|
|
{...restProps}
|
|
|
|
>
|
|
|
|
{icon}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Indicator;
|