Portal/rsconcept/frontend/src/components/control/selector-button.tsx

49 lines
1.1 KiB
TypeScript
Raw Normal View History

2025-02-20 18:10:34 +03:00
import { globalIDs } from '@/utils/constants';
2024-06-07 20:17:03 +03:00
2025-02-20 20:22:05 +03:00
import { type Button } from '../props';
2025-04-12 21:47:46 +03:00
import { cn } from '../utils';
2025-02-20 20:22:05 +03:00
interface SelectorButtonProps extends Button {
/** Text to display in the button. */
2024-06-07 20:17:03 +03:00
text?: string;
/** Icon to display in the button. */
2024-06-07 20:17:03 +03:00
icon?: React.ReactNode;
}
/**
* Displays a button with an icon and text that opens a dropdown menu.
*/
2025-02-07 10:53:49 +03:00
export function SelectorButton({
2024-06-07 20:17:03 +03:00
text,
icon,
title,
titleHtml,
className,
hideTitle,
...restProps
}: SelectorButtonProps) {
return (
<button
type='button'
tabIndex={-1}
2025-04-12 21:47:46 +03:00
className={cn(
2024-06-07 20:17:03 +03:00
'px-1 flex flex-start items-center gap-1',
'text-sm font-controls select-none',
2025-04-12 21:47:46 +03:00
'text-btn cc-controls',
2024-06-18 15:19:04 +03:00
'disabled:cursor-auto cursor-pointer',
2025-04-12 21:47:46 +03:00
'cc-hover cc-animate-color',
2025-02-22 14:03:13 +03:00
className
2024-06-07 20:17:03 +03:00
)}
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 ? icon : null}
2024-08-23 22:53:32 +03:00
{text ? <div className='whitespace-nowrap'>{text}</div> : null}
2024-06-07 20:17:03 +03:00
</button>
);
}