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

59 lines
1.1 KiB
TypeScript
Raw Normal View History

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