ConceptPortal-public/rsconcept/frontend/src/components/ui/Indicator.tsx

40 lines
938 B
TypeScript
Raw Normal View History

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