ConceptPortal-public/rsconcept/frontend/src/components/Common/DropdownButton.tsx

44 lines
963 B
TypeScript
Raw Normal View History

import clsx from 'clsx';
2023-09-02 01:11:27 +03:00
interface DropdownButtonProps {
2023-12-16 19:20:26 +03:00
text?: string
icon?: React.ReactNode
className?: string
2023-09-02 01:11:27 +03:00
tooltip?: string | undefined
2023-07-21 00:09:05 +03:00
onClick?: () => void
disabled?: boolean
2023-12-16 19:20:26 +03:00
children?: React.ReactNode
2023-07-21 00:09:05 +03:00
}
2023-12-16 19:20:26 +03:00
function DropdownButton({
text, icon, children,
tooltip, className,
disabled,
onClick
}: DropdownButtonProps) {
2023-07-21 00:09:05 +03:00
return (
<button type='button'
disabled={disabled}
title={tooltip}
onClick={onClick}
className={clsx(
2023-12-16 19:20:26 +03:00
'px-3 py-1 inline-flex items-center gap-2',
'text-left text-sm overflow-ellipsis whitespace-nowrap',
'disabled:clr-text-controls',
{
'clr-hover': onClick,
'cursor-pointer disabled:cursor-not-allowed': onClick,
'cursor-default': !onClick
2023-12-16 19:20:26 +03:00
},
className
)}
>
2023-12-16 19:20:26 +03:00
{children ? children : null}
{!children && icon ? icon : null}
{!children && text ? <span>{text}</span> : null}
</button>);
2023-07-21 00:09:05 +03:00
}
export default DropdownButton;