diff --git a/packages/frontend/src/components/shared/Sidebar/Sidebar.tsx b/packages/frontend/src/components/shared/Sidebar/Sidebar.tsx index bcd44611..62e25fac 100644 --- a/packages/frontend/src/components/shared/Sidebar/Sidebar.tsx +++ b/packages/frontend/src/components/shared/Sidebar/Sidebar.tsx @@ -1,6 +1,7 @@ import React, { useCallback, useEffect, useState } from 'react'; import { NavLink, useNavigate, useParams } from 'react-router-dom'; import { Organization, User } from 'gql-client'; +import { motion } from 'framer-motion'; import { Option } from '@material-tailwind/react'; import { useDisconnect } from 'wagmi'; @@ -22,12 +23,19 @@ import { Avatar } from 'components/shared/Avatar'; import { formatAddress } from 'utils/format'; import { getInitials } from 'utils/geInitials'; import { Button } from 'components/shared/Button'; +import { cn } from 'utils/classnames'; +import { useMediaQuery } from 'usehooks-ts'; -export const Sidebar = () => { +interface SidebarProps { + mobileOpen?: boolean; +} + +export const Sidebar = ({ mobileOpen }: SidebarProps) => { const { orgSlug } = useParams(); const navigate = useNavigate(); const client = useGQLClient(); const { disconnect } = useDisconnect(); + const isDesktop = useMediaQuery('(min-width: 1024px)'); const [user, setUser] = useState(); @@ -57,11 +65,24 @@ export const Sidebar = () => { disconnect(); navigate('/login'); }, [disconnect, navigate]); - + console.log(isDesktop); return ( - + ); }; diff --git a/packages/frontend/src/pages/org-slug/layout.tsx b/packages/frontend/src/pages/org-slug/layout.tsx index 51325bd4..7ff72e7c 100644 --- a/packages/frontend/src/pages/org-slug/layout.tsx +++ b/packages/frontend/src/pages/org-slug/layout.tsx @@ -1,25 +1,35 @@ import { Logo } from 'components/Logo'; import { Button } from 'components/shared/Button'; import { + CrossIcon, MenuIcon, NotificationBellIcon, SearchIcon, } from 'components/shared/CustomIcon'; import { Sidebar } from 'components/shared/Sidebar'; import { OctokitProvider } from 'context/OctokitContext'; -import React, { ComponentPropsWithoutRef } from 'react'; +import React, { ComponentPropsWithoutRef, useEffect, useState } from 'react'; import { Outlet, useParams } from 'react-router-dom'; +import { AnimatePresence, motion } from 'framer-motion'; import { cn } from 'utils/classnames'; +import { useMediaQuery } from 'usehooks-ts'; export interface DashboardLayoutProps extends ComponentPropsWithoutRef<'section'> {} export const DashboardLayout = ({ className, - children, ...props }: DashboardLayoutProps) => { const { orgSlug } = useParams(); + const isDesktop = useMediaQuery('(min-width: 1024px)'); + const [isSidebarOpen, setIsSidebarOpen] = useState(false); + + useEffect(() => { + if (isDesktop) { + setIsSidebarOpen(false); + } + }, [isDesktop]); return (
- {/* Header on mobile */}
- - - + + {isSidebarOpen ? ( + + + + ) : ( + + <> + + + + + + )} +
-
-
- - - -
+
+ + +
+ + + +
+
- {children}
); };