diff --git a/src/components/Drawer.jsx b/src/components/Drawer.jsx index fb5c4ab7b..5f225db5a 100644 --- a/src/components/Drawer.jsx +++ b/src/components/Drawer.jsx @@ -1,7 +1,7 @@ import { Dialog, Transition } from "@headlessui/react"; import clsx from "clsx"; import PropTypes from "prop-types"; -import React, { Fragment } from "react"; +import React, { Fragment, forwardRef } from "react"; import { CloseIcon } from "../icons"; import { Button } from "./Buttons/Button"; @@ -13,77 +13,78 @@ const sizes = { "2xl": "w-screen md:max-w-screen-md 2xl:max-w-screen-lg", // This was the old size }; -export const Drawer = ({ - isOpen = false, - title, - size = "medium", - content, - onClose, - classNames = {}, - position = "right", -}) => { - return ( - - -
- - - -
+export const Drawer = forwardRef( + ({ isOpen = false, title, size = "medium", content, onClose, classNames = {}, position = "right" }, ref) => { + return ( + + +
+ + +
-
- {position === "right" ? : null} + +
+ {position === "right" ? : null} -
-
- {/* eslint-disable-next-line react/jsx-max-depth */} - {title} +
+
+ {/* eslint-disable-next-line react/jsx-max-depth */} + {title} +
+
+ {content} +
-
{content}
-
- {position === "left" ? : null} -
- + {position === "left" ? : null} +
+
+
-
-
-
- ); -}; +
+
+ ); + }, +); const CloseButton = ({ onClose }) => { return ( @@ -91,21 +92,27 @@ const CloseButton = ({ onClose }) => { size="small" variant="link" className={clsx( - "m-1 inline-flex !h-6 !w-6 items-center justify-center !rounded-full bg-gray !px-1.5", - "!text-white focus:hidden", + "m-2.5 inline-flex !h-10 !w-10 items-center justify-center !rounded-full bg-white !px-1.5", + "!text-black focus:hidden", )} onClick={onClose} > - + ); }; Drawer.propTypes = { - isOpen: PropTypes.bool, + isOpen: PropTypes.bool.isRequired, title: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]), - content: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]), + content: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired, onClose: PropTypes.func.isRequired, classNames: PropTypes.object, position: PropTypes.string, }; + +Drawer.defaultProps = { + title: "", + classNames: {}, + position: "right", +}; diff --git a/src/components/Modal.jsx b/src/components/Modal.jsx index a582ab3e0..7daa04d0a 100644 --- a/src/components/Modal.jsx +++ b/src/components/Modal.jsx @@ -80,7 +80,7 @@ export const Modal = ({ leaveFrom="opacity-100" leaveTo="opacity-0" > - + {/* This element is to trick the browser into centering the modal contents. */} @@ -110,7 +110,7 @@ export const Modal = ({ {onClose ? (