diff --git a/components/core/Layout/Layout.tsx b/components/core/Layout/Layout.tsx index 98efa3824..5209aaa8a 100644 --- a/components/core/Layout/Layout.tsx +++ b/components/core/Layout/Layout.tsx @@ -15,7 +15,7 @@ interface Props { const CoreLayout: FC = ({ className, children }) => { const rootClassName = cn(s.root, className) - const { displaySidebar } = useUI() + const { displaySidebar, closeSidebar } = useUI() return (
@@ -28,7 +28,7 @@ const CoreLayout: FC = ({ className, children }) => {
{children}
- +
diff --git a/components/ui/Sidebar/Sidebar.tsx b/components/ui/Sidebar/Sidebar.tsx index 7459240c4..cc14baf5b 100644 --- a/components/ui/Sidebar/Sidebar.tsx +++ b/components/ui/Sidebar/Sidebar.tsx @@ -1,47 +1,88 @@ import cn from 'classnames' -import { FC } from 'react' +import { FC, useRef } from 'react' import s from './Sidebar.module.css' import { Transition } from '@headlessui/react' +import { + useOverlay, + usePreventScroll, + useModal, + OverlayContainer, +} from '@react-aria/overlays' +import { useDialog } from '@react-aria/dialog' +import { FocusScope } from '@react-aria/focus' + interface Props { className?: string children?: any show?: boolean + close: () => void } -const Sidebar: FC = ({ className, children, show = true }) => { +const Sidebar: FC = ({ className, children, show = true, close }) => { const rootClassName = cn(s.root, className) + + const ref = useRef(null) + const { modalProps } = useModal() + const { overlayProps } = useOverlay( + { + isOpen: show, + onClose: close, + isDismissable: true, + }, + ref + ) + const { dialogProps } = useDialog({}, ref) + + usePreventScroll({ + isDisabled: !show, + }) + return ( -
-
- -
- -
- -
-
- {children} -
-
-
-
-
-
+ + +
+
+ +
+ +
+ +
+
+ {children} +
+
+
+
+
+
+ + ) } diff --git a/pages/_app.tsx b/pages/_app.tsx index 618847986..0e944355a 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,5 +1,6 @@ import { FC } from 'react' import type { AppProps } from 'next/app' +import { SSRProvider, OverlayProvider } from 'react-aria' import '@assets/global.css' import '@assets/tailwind.css' import '@assets/utils.css' @@ -10,8 +11,12 @@ export default function MyApp({ Component, pageProps }: AppProps) { const Layout = (Component as any).Layout || Noop return ( - - - + + + + + + + ) }