diff --git a/website/components/mobile-nav.tsx b/website/components/mobile-nav.tsx new file mode 100644 index 00000000..97c50742 --- /dev/null +++ b/website/components/mobile-nav.tsx @@ -0,0 +1,98 @@ +"use client"; +import React, { useState } from "react"; + +import { ColumnsIcon, Mountain } from "lucide-react"; +import Link, { LinkProps } from "next/link"; +import { usePathname, useRouter } from "next/navigation"; + +import { Button } from "@/components/ui/button"; +import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet"; +import { ScrollArea } from "@/components/ui/scroll-area"; +import { cn } from "@/lib/utils"; +import { mobileSidebar } from "@/lib/sidebar"; + +export function MobileNav() { + const pathname = usePathname(); + const [open, setOpen] = useState(false); + + return ( + + + + + Toggle Menu + + + + + + Starknet React + + + + {mobileSidebar.map((item) => ( + + {item.title} + {item.items.map((subItem) => ( + subItem.href ? ( + + {subItem.title} + + ) : ( + item.title + )))} + + ))} + + + + + ); +} + +interface MobileLinkProps extends LinkProps { + onOpenChange?: (open: boolean) => void + children: React.ReactNode + className?: string +} + +function MobileLink({ + href, + onOpenChange, + className, + children, + ...props +}: MobileLinkProps) { + const router = useRouter() + + return ( + { + router.push(href.toString()) + onOpenChange?.(false) + }} + className={cn(className)} + {...props} + > + {children} + + ) +} diff --git a/website/components/site-header.tsx b/website/components/site-header.tsx index 5af737a7..1f733a1a 100644 --- a/website/components/site-header.tsx +++ b/website/components/site-header.tsx @@ -7,13 +7,15 @@ import { MainNav } from "@/components/main-nav"; import { buttonVariants } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import { ModeToggle } from "./theme-toggle"; +import { MobileNav } from "./mobile-nav"; export function SiteHeader() { return ( - + + , + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +SheetOverlay.displayName = SheetPrimitive.Overlay.displayName + +const sheetVariants = cva( + "fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500", + { + variants: { + side: { + top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top", + bottom: + "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom", + left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm", + right: + "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm", + }, + }, + defaultVariants: { + side: "right", + }, + } +) + +interface SheetContentProps + extends React.ComponentPropsWithoutRef, + VariantProps {} + +const SheetContent = React.forwardRef< + React.ElementRef, + SheetContentProps +>(({ side = "right", className, children, ...props }, ref) => ( + + + + {children} + + + Close + + + +)) +SheetContent.displayName = SheetPrimitive.Content.displayName + +const SheetHeader = ({ + className, + ...props +}: React.HTMLAttributes) => ( + +) +SheetHeader.displayName = "SheetHeader" + +const SheetFooter = ({ + className, + ...props +}: React.HTMLAttributes) => ( + +) +SheetFooter.displayName = "SheetFooter" + +const SheetTitle = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +SheetTitle.displayName = SheetPrimitive.Title.displayName + +const SheetDescription = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +SheetDescription.displayName = SheetPrimitive.Description.displayName + +export { + Sheet, + SheetPortal, + SheetOverlay, + SheetTrigger, + SheetClose, + SheetContent, + SheetHeader, + SheetFooter, + SheetTitle, + SheetDescription, +} diff --git a/website/lib/sidebar.ts b/website/lib/sidebar.ts index 07bfe1ef..4e662c70 100644 --- a/website/lib/sidebar.ts +++ b/website/lib/sidebar.ts @@ -36,3 +36,8 @@ export const docsSidebar: NavItemWithChildren[] = [ })), } ]; + +export const mobileSidebar: NavItemWithChildren[] = [ + ...docsSidebar, + ...demoSidebar, +];