diff --git a/app/providers.tsx b/app/providers.tsx index b702f77..e568715 100644 --- a/app/providers.tsx +++ b/app/providers.tsx @@ -2,20 +2,57 @@ import Navbar from "@/components/custom/navbar"; import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@/components/ui/resizable"; -import { SessionProvider } from "next-auth/react"; +import { Info, LogOut, Waypoints } from "lucide-react"; +import { SessionProvider, signOut } from "next-auth/react"; import { ThemeProvider } from 'next-themes' +import { useRef, useState } from "react"; +import { ImperativePanelHandle } from "react-resizable-panels"; type Props = { children?: React.ReactNode; }; + +const LINKS = [ + { + name: "Connection Details", + href: "/details", + icon: (), + }, + { + name: "Graph", + href: "/graph", + icon: (), + }, + { + name: "Sign Out", + href: "/", + icon: (), + onClick: () => { signOut({ callbackUrl: '/' }) } + }, +] + 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) }}> + {children} diff --git a/components/custom/navbar.tsx b/components/custom/navbar.tsx index 9b313c3..be0dc98 100644 --- a/components/custom/navbar.tsx +++ b/components/custom/navbar.tsx @@ -1,5 +1,5 @@ -import { Info, LogOut, Menu, Waypoints } from "lucide-react"; -import { signOut, useSession } from "next-auth/react"; +import { Menu } from "lucide-react"; +import { useSession } from "next-auth/react"; import Link from "next/link"; import { Switch } from "../ui/switch"; import { Label } from "../ui/label"; @@ -7,7 +7,15 @@ import { useEffect, useState } from "react"; import { useTheme } from "next-themes"; import { GithubMark } from "./GithubMark"; -export default function Navbar() { + +export interface LinkDefinition { + name: string, + href: string, + icon: JSX.Element, + onClick?: () => void +} + +export default function Navbar(params: { links: LinkDefinition[], collapsed: boolean, onExpand:()=>void }) { const { data: session, status } = useSession() const { theme, setTheme, systemTheme } = useTheme() @@ -29,68 +37,39 @@ export default function Navbar() { let darkmode = theme == "dark" || (theme == "system" && systemTheme == "dark") return ( )