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

46 lines
1.0 KiB
TypeScript
Raw Normal View History

import clsx from 'clsx';
import { motion } from 'framer-motion';
import { animateDropdown } from '@/styling/animations';
import { CProps } from '../props';
2023-12-28 14:04:44 +03:00
interface DropdownProps extends CProps.Styling {
stretchLeft?: boolean;
2024-06-26 19:00:29 +03:00
stretchTop?: boolean;
2023-12-28 14:04:44 +03:00
isOpen: boolean;
children: React.ReactNode;
2023-07-20 17:11:03 +03:00
}
2024-06-26 19:00:29 +03:00
function Dropdown({ isOpen, stretchLeft, stretchTop, className, children, ...restProps }: DropdownProps) {
2023-07-20 17:11:03 +03:00
return (
2023-12-28 14:04:44 +03:00
<div className='relative'>
<motion.div
2024-05-11 20:53:36 +03:00
tabIndex={-1}
2023-12-28 14:04:44 +03:00
className={clsx(
'z-modalTooltip',
2023-12-28 14:04:44 +03:00
'absolute mt-3',
'flex flex-col',
'border rounded-md shadow-lg',
'text-sm',
'clr-input',
{
'right-0': stretchLeft,
2024-06-26 19:00:29 +03:00
'left-0': !stretchLeft,
'bottom-[2rem]': stretchTop
2023-12-28 14:04:44 +03:00
},
className
)}
initial={false}
animate={isOpen ? 'open' : 'closed'}
variants={animateDropdown}
{...restProps}
>
{children}
</motion.div>
</div>
);
2023-07-20 17:11:03 +03:00
}
2023-12-28 14:04:44 +03:00
export default Dropdown;