2024-09-12 14:48:08 +03:00
|
|
|
import clsx from 'clsx';
|
|
|
|
|
2025-01-28 23:23:42 +03:00
|
|
|
import { CProps } from '@/components/props';
|
2024-09-12 14:48:08 +03:00
|
|
|
import { globals } from '@/utils/constants';
|
|
|
|
|
|
|
|
interface IndicatorProps extends CProps.Titled, CProps.Styling {
|
2024-09-12 16:42:02 +03:00
|
|
|
/** Icon to display. */
|
2024-09-12 14:48:08 +03:00
|
|
|
icon: React.ReactNode;
|
2024-09-12 16:42:02 +03:00
|
|
|
|
|
|
|
/** Indicates whether the indicator should have no padding. */
|
2024-09-12 14:48:08 +03:00
|
|
|
noPadding?: boolean;
|
|
|
|
}
|
|
|
|
|
2024-09-12 16:42:02 +03:00
|
|
|
/**
|
2024-10-30 21:35:55 +03:00
|
|
|
* Displays a status `icon` with a tooltip.
|
2024-09-12 16:42:02 +03:00
|
|
|
*/
|
2025-02-07 10:54:47 +03:00
|
|
|
export function Indicator({ icon, title, titleHtml, hideTitle, noPadding, className, ...restProps }: IndicatorProps) {
|
2024-09-12 14:48:08 +03:00
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className={clsx(
|
2024-12-17 11:38:00 +03:00
|
|
|
'clr-text-controls',
|
2024-09-12 14:48:08 +03:00
|
|
|
'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>
|
|
|
|
);
|
|
|
|
}
|