2024-06-07 20:17:03 +03:00
|
|
|
import clsx from 'clsx';
|
|
|
|
|
2025-02-20 18:10:34 +03:00
|
|
|
import { globalIDs } from '@/utils/constants';
|
2024-06-07 20:17:03 +03:00
|
|
|
|
2025-02-10 01:32:16 +03:00
|
|
|
import { CProps } from '../props';
|
|
|
|
|
2024-06-07 20:17:03 +03:00
|
|
|
interface MiniButtonProps extends CProps.Button {
|
2025-02-07 15:21:40 +03:00
|
|
|
/** Button type. */
|
|
|
|
type?: 'button' | 'submit';
|
|
|
|
|
2024-11-21 15:09:31 +03:00
|
|
|
/** Icon to display in the button. */
|
2024-06-07 20:17:03 +03:00
|
|
|
icon: React.ReactNode;
|
2024-11-21 15:09:31 +03:00
|
|
|
|
|
|
|
/** Disable hover effect. */
|
2024-06-07 20:17:03 +03:00
|
|
|
noHover?: boolean;
|
2024-11-21 15:09:31 +03:00
|
|
|
|
|
|
|
/** Disable padding. */
|
2024-06-07 20:17:03 +03:00
|
|
|
noPadding?: boolean;
|
|
|
|
}
|
|
|
|
|
2024-11-21 15:09:31 +03:00
|
|
|
/**
|
|
|
|
* Displays small transparent button with an icon.
|
|
|
|
*/
|
2025-02-07 10:53:49 +03:00
|
|
|
export function MiniButton({
|
2024-06-07 20:17:03 +03:00
|
|
|
icon,
|
|
|
|
noHover,
|
|
|
|
noPadding,
|
|
|
|
tabIndex,
|
|
|
|
title,
|
|
|
|
titleHtml,
|
|
|
|
hideTitle,
|
2025-02-07 15:21:40 +03:00
|
|
|
type = 'button',
|
2024-06-07 20:17:03 +03:00
|
|
|
className,
|
|
|
|
...restProps
|
|
|
|
}: MiniButtonProps) {
|
|
|
|
return (
|
|
|
|
<button
|
2025-02-07 15:21:40 +03:00
|
|
|
type={type}
|
2024-06-07 20:17:03 +03:00
|
|
|
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
|
|
|
|
)}
|
2025-02-20 18:10:34 +03:00
|
|
|
data-tooltip-id={!!title || !!titleHtml ? globalIDs.tooltip : undefined}
|
2024-06-07 20:17:03 +03:00
|
|
|
data-tooltip-html={titleHtml}
|
|
|
|
data-tooltip-content={title}
|
|
|
|
data-tooltip-hidden={hideTitle}
|
|
|
|
{...restProps}
|
|
|
|
>
|
|
|
|
{icon}
|
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|