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

61 lines
1.2 KiB
TypeScript
Raw Normal View History

import clsx from 'clsx';
2025-02-20 18:10:53 +03:00
import { globalIDs } from '@/utils/constants';
2023-12-21 00:12:24 +03:00
import { type Button } from '../props';
interface MiniButtonProps extends Button {
2025-02-07 15:30:47 +03:00
/** Button type. */
type?: 'button' | 'submit';
/** 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.
*/
2025-02-07 10:54:47 +03:00
export function MiniButton({
icon,
noHover,
noPadding,
tabIndex,
title,
titleHtml,
2024-03-09 16:40:10 +03:00
hideTitle,
2025-02-07 15:30:47 +03:00
type = 'button',
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(
'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,
'outline-hidden': noHover,
2023-12-28 14:04:44 +03:00
'clr-hover': !noHover
},
className
)}
2025-02-20 18:10:53 +03:00
data-tooltip-id={!!title || !!titleHtml ? globalIDs.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
}