2023-12-15 17:34:50 +03:00
|
|
|
import clsx from 'clsx';
|
|
|
|
|
2024-03-27 15:32:59 +03:00
|
|
|
import { globals } from '@/utils/constants';
|
2023-12-21 00:12:24 +03:00
|
|
|
|
2025-02-10 01:32:55 +03:00
|
|
|
import { CProps } from '../props';
|
|
|
|
|
2023-12-28 14:04:44 +03:00
|
|
|
interface MiniButtonProps extends CProps.Button {
|
2025-02-07 15:30:47 +03:00
|
|
|
/** Button type. */
|
|
|
|
type?: 'button' | 'submit';
|
|
|
|
|
2024-11-21 15:09:51 +03:00
|
|
|
/** Icon to display in the button. */
|
2023-12-28 14:04:44 +03:00
|
|
|
icon: React.ReactNode;
|
2024-11-21 15:09:51 +03:00
|
|
|
|
|
|
|
/** Disable hover effect. */
|
2023-12-28 14:04:44 +03:00
|
|
|
noHover?: boolean;
|
2024-11-21 15:09:51 +03:00
|
|
|
|
|
|
|
/** Disable padding. */
|
2024-03-27 22:54:24 +03:00
|
|
|
noPadding?: boolean;
|
2023-07-27 22:04:25 +03:00
|
|
|
}
|
|
|
|
|
2024-11-21 15:09:51 +03:00
|
|
|
/**
|
|
|
|
* Displays small transparent button with an icon.
|
|
|
|
*/
|
2025-02-07 10:54:47 +03:00
|
|
|
export function MiniButton({
|
2024-03-08 18:39:08 +03:00
|
|
|
icon,
|
|
|
|
noHover,
|
2024-03-27 22:54:24 +03:00
|
|
|
noPadding,
|
2024-03-08 18:39:08 +03:00
|
|
|
tabIndex,
|
|
|
|
title,
|
|
|
|
titleHtml,
|
2024-03-09 16:40:10 +03:00
|
|
|
hideTitle,
|
2025-02-07 15:30:47 +03:00
|
|
|
type = 'button',
|
2024-03-08 18:39:08 +03:00
|
|
|
className,
|
|
|
|
...restProps
|
|
|
|
}: MiniButtonProps) {
|
2023-07-27 22:04:25 +03:00
|
|
|
return (
|
2023-12-28 14:04:44 +03:00
|
|
|
<button
|
2025-02-07 15:30:47 +03:00
|
|
|
type={type}
|
2023-12-28 14:04:44 +03:00
|
|
|
tabIndex={tabIndex ?? -1}
|
|
|
|
className={clsx(
|
2024-04-03 18:48:56 +03:00
|
|
|
'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
|
|
|
{
|
2024-03-27 22:54:24 +03:00
|
|
|
'px-1 py-1': !noPadding,
|
2023-12-28 14:04:44 +03:00
|
|
|
'outline-none': noHover,
|
|
|
|
'clr-hover': !noHover
|
|
|
|
},
|
|
|
|
className
|
|
|
|
)}
|
2024-03-27 15:32:59 +03:00
|
|
|
data-tooltip-id={!!title || !!titleHtml ? globals.tooltip : undefined}
|
2024-03-08 18:39:08 +03:00
|
|
|
data-tooltip-html={titleHtml}
|
2023-12-28 14:04:44 +03:00
|
|
|
data-tooltip-content={title}
|
2024-02-03 15:33:28 +03:00
|
|
|
data-tooltip-hidden={hideTitle}
|
2023-12-28 14:04:44 +03:00
|
|
|
{...restProps}
|
|
|
|
>
|
|
|
|
{icon}
|
|
|
|
</button>
|
|
|
|
);
|
2023-07-27 22:04:25 +03:00
|
|
|
}
|