import classnames from 'classnames' import { useLayoutEffect, useRef, RefObject } from 'react' import { createPortal } from 'react-dom' import { Card } from '@components' import { BaseComponentProps } from '@models/BaseProps' interface DrawerProps extends BaseComponentProps { visible?: boolean width?: number containerRef?: RefObject } export function Drawer (props: DrawerProps) { const portalRef = useRef(document.createElement('div')) useLayoutEffect(() => { const current = portalRef.current document.body.appendChild(current) return () => { document.body.removeChild(current) } }, []) const cardStyle = 'absolute h-full right-0 transition-transform transform translate-x-full duration-100 pointer-events-auto' const container = (
{props.children}
) return createPortal(container, props.containerRef?.current ?? portalRef.current) }