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

47 lines
890 B
TypeScript
Raw Normal View History

import clsx from 'clsx';
import { motion } from 'framer-motion';
import { animateDropdown } from '@/utils/animations';
import { CProps } from '../props';
interface DropdownProps
extends CProps.Styling {
2023-07-20 17:11:03 +03:00
stretchLeft?: boolean
isOpen: boolean
children: React.ReactNode
2023-07-20 17:11:03 +03:00
}
function Dropdown({
isOpen, stretchLeft,
className,
children,
...restProps
}: DropdownProps) {
2023-07-20 17:11:03 +03:00
return (
<div className='relative'>
<motion.div
className={clsx(
'z-modal-tooltip',
'absolute mt-3',
'flex flex-col',
'border rounded-md shadow-lg',
'text-sm',
'clr-input',
{
'right-0': stretchLeft,
'left-0': !stretchLeft
},
className
)}
initial={false}
animate={isOpen ? 'open' : 'closed'}
variants={animateDropdown}
{...restProps}
>
2023-12-04 14:19:54 +03:00
{children}
</motion.div>
</div>);
2023-07-20 17:11:03 +03:00
}
export default Dropdown;