import React, { ReactNode, useState } from "react"; import { Drawer as ChakraDrawer, DrawerBody, DrawerHeader, DrawerOverlay, DrawerContent, IconButton, useColorModeValue, DrawerCloseButton, DrawerProps as ChakraDrawerProps, } from "@chakra-ui/react"; import { RiArrowLeftSLine, RiArrowRightSLine } from "react-icons/ri"; export interface DrawerProps extends ChakraDrawerProps { isOpen: boolean; onClose(): void; children: ReactNode; title?: any; expandButton?: boolean; closeButton?: boolean; drawerBgColor?: string; expandedSize?: | "xl" | "sm" | "xs" | "md" | "lg" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "full"; size?: | "xl" | "sm" | "xs" | "md" | "lg" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "full"; } export function Drawer({ isOpen, onClose, children, expandButton = true, closeButton = true, title, drawerBgColor, size = "sm", expandedSize = "xl", ...rest }: DrawerProps) { const [expanded, setExpanded] = useState(false); const drawerBgDefault = useColorModeValue("gray.50", "gray.800"); const drawerBg = drawerBgColor || drawerBgDefault; return ( <> {closeButton && } {expandButton && ( ) : ( ) } onClick={() => setExpanded(!expanded)} /> )} {title && title} {children && {children}} ); }