Portal/rsconcept/frontend/src/components/ui/MiniButton.tsx

58 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-06-07 20:17:03 +03:00
import clsx from 'clsx';
2025-01-28 23:23:03 +03:00
import { CProps } from '@/components/props';
2024-06-07 20:17:03 +03:00
import { globals } from '@/utils/constants';
interface MiniButtonProps extends CProps.Button {
/** Icon to display in the button. */
2024-06-07 20:17:03 +03:00
icon: React.ReactNode;
/** Disable hover effect. */
2024-06-07 20:17:03 +03:00
noHover?: boolean;
/** Disable padding. */
2024-06-07 20:17:03 +03:00
noPadding?: boolean;
}
/**
* Displays small transparent button with an icon.
*/
2024-06-07 20:17:03 +03:00
function MiniButton({
icon,
noHover,
noPadding,
tabIndex,
title,
titleHtml,
hideTitle,
className,
...restProps
}: MiniButtonProps) {
return (
<button
type='button'
tabIndex={tabIndex ?? -1}
className={clsx(
'rounded-lg',
2024-12-17 11:37:42 +03:00
'clr-text-controls cc-animate-color',
2024-06-18 15:19:04 +03:00
'cursor-pointer disabled:cursor-auto',
2024-06-07 20:17:03 +03:00
{
'px-1 py-1': !noPadding,
'outline-none': noHover,
'clr-hover': !noHover
},
className
)}
data-tooltip-id={!!title || !!titleHtml ? globals.tooltip : undefined}
data-tooltip-html={titleHtml}
data-tooltip-content={title}
data-tooltip-hidden={hideTitle}
{...restProps}
>
{icon}
</button>
);
}
export default MiniButton;