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

54 lines
1.2 KiB
TypeScript
Raw Normal View History

import clsx from 'clsx';
2023-12-21 00:12:24 +03:00
import { globalIDs } from '@/utils/constants';
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'
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',
'disabled:cursor-not-allowed cursor-pointer',
{
'clr-hover': transparent,
'border': !transparent
},
className,
!transparent && colors
)}
data-tooltip-id={!!title || !!titleHtml ? globalIDs.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}
2023-12-30 19:43:24 +03:00
{text ? <div className={'whitespace-nowrap pb-1'}>{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;