diff --git a/app/providers.tsx b/app/providers.tsx index 94e51d3..e568715 100644 --- a/app/providers.tsx +++ b/app/providers.tsx @@ -5,7 +5,8 @@ import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@/componen import { Info, LogOut, Waypoints } from "lucide-react"; import { SessionProvider, signOut } from "next-auth/react"; import { ThemeProvider } from 'next-themes' -import { useState } from "react"; +import { useRef, useState } from "react"; +import { ImperativePanelHandle } from "react-resizable-panels"; type Props = { children?: React.ReactNode; @@ -34,13 +35,24 @@ const LINKS = [ export const NextAuthProvider = ({ children }: Props) => { const [isCollapsed, setCollapsed] = useState(false) + let navPanel = useRef(null) + + function onExpand(){ + if(navPanel.current){ + if(navPanel.current.isCollapsed()){ + navPanel.current.expand() + } else { + navPanel.current.collapse() + } + } + } return ( - { setCollapsed(true) }} onExpand={() => { setCollapsed(false) }}> - + { setCollapsed(true) }} onExpand={() => { setCollapsed(false) }}> + {children} diff --git a/components/custom/navbar.tsx b/components/custom/navbar.tsx index 05aadbd..be0dc98 100644 --- a/components/custom/navbar.tsx +++ b/components/custom/navbar.tsx @@ -15,7 +15,7 @@ export interface LinkDefinition { onClick?: () => void } -export default function Navbar(params: { links: LinkDefinition[], collapsed: boolean }) { +export default function Navbar(params: { links: LinkDefinition[], collapsed: boolean, onExpand:()=>void }) { const { data: session, status } = useSession() const { theme, setTheme, systemTheme } = useTheme() @@ -37,6 +37,10 @@ export default function Navbar(params: { links: LinkDefinition[], collapsed: boo let darkmode = theme == "dark" || (theme == "system" && systemTheme == "dark") return (