⌘K
Search
Search pages, pieces and blocks.
Site nav/The top of a site: the brand, four links with the current one marked, one action; on a phone the links fold into a Sheet.
components/blocks/site-nav.tsx
"use client"
import * as React from "react"
import { MenuIcon, WavesIcon } from "@/components/icons"import { BrandMark } from "@/components/ui/brand-mark"import { Button } from "@/components/ui/button"import { NavItem, NavList } from "@/components/ui/nav-item"import { NavigationMenu, NavigationMenuItem, NavigationMenuLink, NavigationMenuList,} from "@/components/ui/navigation-menu"import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from "@/components/ui/sheet"import { Text } from "@/components/ui/text"
// Site nav: the top of a site built on António. The Maré mark and name, four// links with the current one marked, and one primary action. Three columns,// the outer two equal, so the links sit on the page's middle. Below 768px the// links fold into a menu button that opens a Sheet from the end side; the// primary action stays in the bar.
const links = ["Lessons", "Schools", "Pricing", "Questions"]
function SiteNavBlock() { const [current, setCurrent] = React.useState("Lessons") const [open, setOpen] = React.useState(false)
return ( <header className="mx-auto flex h-16 w-full max-w-6xl items-center gap-6 px-6"> <div className="flex flex-1"> <a href="#" className="flex shrink-0 items-center gap-2.5"> <BrandMark> <WavesIcon /> </BrandMark> <Text variant="strong">Maré</Text> </a> </div>
<NavigationMenu aria-label="Main" className="hidden max-w-none md:flex"> <NavigationMenuList> {links.map((link) => ( <NavigationMenuItem key={link}> <NavigationMenuLink href="#" active={current === link} aria-current={current === link ? "page" : undefined} onClick={(event) => { event.preventDefault() setCurrent(link) }} > {link} </NavigationMenuLink> </NavigationMenuItem> ))} </NavigationMenuList> </NavigationMenu>
<div className="flex flex-1 items-center justify-end gap-2"> <Button>Book a lesson</Button> <Sheet open={open} onOpenChange={setOpen}> <SheetTrigger render={<Button variant="ghost" size="icon" aria-label="Menu" className="md:hidden" />}> <MenuIcon /> </SheetTrigger> <SheetContent side="right"> <SheetHeader> <SheetTitle>Menu</SheetTitle> </SheetHeader> <nav aria-label="Main" className="px-2"> <NavList> {links.map((link) => ( <NavItem key={link} href="#" active={current === link} className="h-11" onClick={(event) => { event.preventDefault() setCurrent(link) setOpen(false) }} > {link} </NavItem> ))} </NavList> </nav> </SheetContent> </Sheet> </div> </header> )}
export { SiteNavBlock }