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

55 lines
1.2 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 SelectorButtonProps extends CProps.Button {
text?: string;
icon?: React.ReactNode;
2023-12-28 14:04:44 +03:00
colors?: string;
transparent?: boolean;
2023-10-06 14:39:32 +03:00
}
function SelectorButton({
2023-12-28 14:04:44 +03:00
text,
icon,
title,
titleHtml,
2023-11-05 16:31:49 +03:00
colors = 'clr-btn-default',
className,
2023-10-06 14:39:32 +03:00
transparent,
hideTitle,
...restProps
2023-10-06 14:39:32 +03:00
}: SelectorButtonProps) {
return (
2023-12-28 14:04:44 +03:00
<button
type='button'
tabIndex={-1}
2023-12-28 14:04:44 +03:00
className={clsx(
'px-1 flex flex-start items-center gap-1',
2023-12-30 19:43:24 +03:00
'text-sm font-controls select-none',
2023-12-28 14:04:44 +03:00
'text-btn clr-text-controls',
2024-06-18 15:19:19 +03:00
'disabled:cursor-auto cursor-pointer',
2023-12-28 14:04:44 +03:00
{
'clr-hover': transparent,
'border': !transparent
},
className,
!transparent && colors
)}
data-tooltip-id={!!title || !!titleHtml ? globals.tooltip : undefined}
data-tooltip-html={titleHtml}
data-tooltip-content={title}
data-tooltip-hidden={hideTitle}
2023-12-28 14:04:44 +03:00
{...restProps}
>
{icon ? icon : null}
2024-04-03 15:51:57 +03:00
{text ? <div className={'whitespace-nowrap'}>{text}</div> : null}
2023-12-28 14:04:44 +03:00
</button>
);
2023-10-06 14:39:32 +03:00
}
2023-12-28 14:04:44 +03:00
export default SelectorButton;