import { GlobalCommandPalette, type NavigationItem, } from "@/components/GlobalCommandPalette" import { HistoryDrawer, HistoryDrawerTrigger } from "@/components/Workspace" import { GithubIcon } from "@/components/Icons" import SliderToggle from "@/components/Toggle" import { Button } from "@/components/ui/button" import { Sheet, SheetContent } from "@/components/ui/sheet" import { Link } from "@/hashParams" import { changeTheme, useTheme } from "@/ThemeProvider" import { BookOpenText, Cable, DatabaseSearch, GitGraph, Menu, MoonStar, Send, ServerCog, SquareEqual, SquareFunction, UserRound, } from "lucide-react" import { FC, PropsWithChildren, useState } from "react" import { useLocation } from "react-router-dom" import { twMerge } from "tailwind-merge" import { NetworkSwitcher } from "./Network/Network" const navigationGroups: Array<{ label: string items: NavigationItem[] }> = [ { label: "Dev Tools", items: [ { path: "/explorer", label: "Explorer", // Alts GitFork, GitBranch icon: GitGraph, }, { path: "/storage", label: "Storage", icon: DatabaseSearch, }, { path: "/extrinsics", label: "Extrinsics", icon: Send, }, { path: "/runtimeCalls", label: "Runtime Calls", // Alt SquareTerminal icon: ServerCog, }, { path: "/viewFns", label: "View Functions", icon: SquareFunction, }, { path: "/constants", label: "Constants", // Alt Braces icon: SquareEqual, }, { path: "/metadata", label: "Metadata", // Alt Boxes icon: BookOpenText, }, { path: "/rpcCalls", label: "RPC Calls", // Alt RadioTower icon: Cable, }, ], }, { label: "Utilities", items: [ { path: "/accounts", label: "Accounts", // Alt Wallet icon: UserRound, }, ], }, ] const navigationItems = navigationGroups.flatMap((group) => group.items) export const AppShell: FC = ({ children }) => { const [sidebarOpen, setSidebarOpen] = useState(false) return (
setSidebarOpen(false)} mobile />
setSidebarOpen(true)} />
{children}
) } const SidebarContent: FC<{ mobile?: boolean; onNavigate?: () => void }> = ({ mobile, onNavigate, }) => (
papi logo papi logo
papi{" "} console
beta
{mobile ? (
) : null}
GitHub
) const TopBar: FC<{ onOpenSidebar: () => void }> = ({ onOpenSidebar }) => { return (
) } const SidebarLink: FC<{ item: NavigationItem; onClick?: () => void }> = ({ item, onClick, }) => { const location = useLocation() const active = isNavigationItemActive(location.pathname, item.path) const Icon = item.icon return ( {item.label} ) } const isNavigationItemActive = (pathname: string, path: string) => pathname === path || pathname.startsWith(`${path}/`) const ThemeToggle = () => { const theme = useTheme() return ( ) }