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

49 lines
1.2 KiB
TypeScript
Raw Normal View History

import clsx from 'clsx';
import { motion } from 'framer-motion';
import { animateDropdownItem } from '@/utils/animations';
2023-12-21 00:12:24 +03:00
import { globalIDs } from '@/utils/constants';
import { CProps } from '../props';
interface DropdownButtonProps
extends CProps.AnimatedButton {
2023-12-16 19:20:26 +03:00
text?: string
icon?: React.ReactNode
children?: React.ReactNode
2023-07-21 00:09:05 +03:00
}
2023-12-16 19:20:26 +03:00
function DropdownButton({
2023-12-21 00:12:24 +03:00
text, icon,
className, title,
onClick,
children,
...restProps
2023-12-16 19:20:26 +03:00
}: DropdownButtonProps) {
2023-07-21 00:09:05 +03:00
return (
<motion.button type='button'
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
)}
variants={animateDropdownItem}
2023-12-21 00:12:24 +03:00
data-tooltip-id={title ? (globalIDs.tooltip) : undefined}
data-tooltip-content={title}
{...restProps}
>
2023-12-16 19:20:26 +03:00
{children ? children : null}
{!children && icon ? icon : null}
{!children && text ? <span>{text}</span> : null}
</motion.button>);
2023-07-21 00:09:05 +03:00
}
export default DropdownButton;