Files
supabase/apps/ui-library/components/site-header.tsx
3f205627e0 feat(library): redesign the site around the block catalog (#50372)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Feature — the visual redesign itself.

Part 5 of 6 in a stack that splits the library redesign into reviewable
pieces. The four PRs beneath it carry the build, content and Markdown
work; what's left here is layout, navigation and styling.

## What is the current behavior?

The library is laid out like a documentation site: a sidebar tree of
framework folders, a homepage that lists links, and a guide page that
opens with prose. That shape suits reference material, but the library's
job is to help someone find a block and install it — and the sidebar is
the only way to discover one.

## What is the new behavior?

The homepage is the catalog itself — blocks grouped by what they do
(authentication, database, storage, realtime, messaging, AI,
foundations) rather than by framework, each with a preview of what it
renders, filterable by category.

Navigation moves into a site header whose Explore menu opens the same
categories, so the catalog is reachable from any page and the per-page
sidebar tree is gone.

A guide opens with what the reader came for: the block's name, the
install command, and a preview pane with tabs — the running component
and its files — before any prose. The file tree that used to sit
mid-page under "Folder structure" is one of those tabs. Every guide also
offers a copy of the agent prompt that points at its Markdown.

Getting-started pages get the same treatment: the quickstart is now a
framework-tabbed walkthrough rather than a wall of setup links.

## Additional context

`BlockOverviewTabs` renders Preview and Files here. #50369, stacked on
top of this one, adds the third "What's added" tab — it is the only part
of the redesign that depends on the new resource analyzer, which is why
it sits above this PR rather than below it.

Also removes what the redesign orphaned: the table-of-contents component
and its `remark` / `mdast-util-toc` dependencies, and the sidebar nav
and command-item configuration the new header replaced.

The block source changes are typography only — auth card titles move
from `text-2xl` to `font-medium text-lg tracking-normal` — which is what
regenerates the auth registry artifacts.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added a redesigned Supabase Library catalog with categorized blocks,
framework-aware navigation, previews, file views, and installation
actions.
* Added framework-specific quickstart guides for Next.js, React, Vue,
Nuxt, React Router, and TanStack Start.
* Added copy-to-clipboard prompts, “Open in v0” actions, starter
templates, and richer visual previews.

* **Improvements**
* Updated documentation layouts, FAQ content, typography, navigation,
accessibility, and responsive behavior.
* Improved mobile navigation, framework selection, and standardized
block installation guidance.
* Refined authentication and social-login block presentation with more
consistent heading styles.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Danny White <3104761+dnywh@users.noreply.github.com>
2026-09-29 10:45:23 +10:00

206 lines
9.5 KiB
TypeScript

'use client'
import supabaseLogoIcon from 'common/assets/images/supabase-logo-icon.svg'
import { ArrowUpRight, ChevronRight, Code2, Grid2X2 } from 'lucide-react'
import Image from 'next/image'
import Link from 'next/link'
import { useState } from 'react'
import {
Button,
buttonVariants,
cn,
NavigationMenu,
NavigationMenuContent,
NavigationMenuItem,
NavigationMenuLink,
NavigationMenuList,
NavigationMenuTrigger,
Tabs,
TabsContent,
TabsList,
TabsTrigger,
} from 'ui'
import { CommandMenu } from '@/components/command-menu'
import { Sidebar } from '@/components/sidebar'
import { ThemeSwitcherDropdown } from '@/components/theme-switcher-dropdown'
import { getLibraryBlockHref, libraryBlocks, libraryCategories } from '@/config/library'
import { useFramework } from '@/context/framework-context'
import { useMenuAim } from '@/hooks/use-menu-aim'
export function SiteHeader() {
const { framework } = useFramework()
const [activeCategory, setActiveCategory] = useState<string>(libraryCategories[0].name)
const menuAim = useMenuAim(activeCategory, setActiveCategory)
return (
<header className="sticky top-0 z-40 before:pointer-events-none before:absolute before:inset-x-0 before:top-0 before:h-24 before:bg-gradient-to-b before:from-background before:via-background/90 before:via-60% before:to-transparent">
<a
href="#main-content"
className="sr-only focus:not-sr-only focus:absolute focus:z-50 focus:bg-background focus:p-3"
>
Skip to content
</a>
<div className="relative mx-auto flex h-14 max-w-site items-center justify-between gap-4 px-4 md:px-8">
<div className="flex shrink-0 items-center gap-4 lg:gap-8">
<Link
href="/"
className="flex items-center gap-2 text-sm font-medium tracking-tight"
aria-label="Supabase Library home"
>
<Image src={supabaseLogoIcon} alt="" width={24} height={24} />
<span aria-hidden="true" className="text-border">
/
</span>
<span className="text-foreground-light">Library</span>
</Link>
</div>
<nav aria-label="Main navigation" className="absolute left-1/2 -translate-x-1/2">
<NavigationMenu
delayDuration={0}
className="hidden h-14 md:flex md:flex-none [&>div:last-child]:left-1/2 [&>div:last-child]:-translate-x-1/2"
viewportClassName="rounded-xl bg-background data-[state=open]:slide-in-from-right-0!"
>
<NavigationMenuList className="flex-none gap-1">
<NavigationMenuItem>
<NavigationMenuTrigger
className={cn(
buttonVariants({ variant: 'text', size: 'small' }),
'h-8 rounded-full px-3 text-foreground-light hover:text-foreground data-[state=open]:text-foreground'
)}
>
<Grid2X2 aria-hidden="true" className="size-4 text-muted-foreground" />
<span className="font-medium text-foreground">Explore</span>
</NavigationMenuTrigger>
<NavigationMenuContent>
<Tabs
value={activeCategory}
onValueChange={menuAim.selectCategory}
onPointerMove={menuAim.onPointerMove}
onPointerLeave={menuAim.onPointerLeave}
orientation="vertical"
className="flex w-[640px] max-w-[calc(100vw-4rem)] max-h-[calc(100dvh-5rem)] overflow-y-auto"
>
<div className="flex w-60 shrink-0 flex-col border-r bg-surface-75 py-2">
<TabsList
aria-label="Block categories"
className="h-auto flex-col items-stretch justify-start border-b-0"
>
{libraryCategories.map((category) => (
<TabsTrigger
key={category.name}
value={category.name}
data-menu-category={category.name}
className="justify-between gap-3 whitespace-normal border-0 px-4 py-2.5 text-left data-[state=active]:bg-surface-200 data-[state=active]:shadow-none"
>
{category.name}
<ChevronRight
size={14}
className="shrink-0 text-foreground-lighter group-data-[state=active]:text-primary"
/>
</TabsTrigger>
))}
</TabsList>
<ul className="mx-4 mt-5 flex flex-col border-t pt-2.5">
{[
{ href: '/', label: 'Browse all blocks' },
{ href: '/docs/getting-started/quickstart', label: 'Quickstart' },
{ href: '/docs/getting-started/faq', label: 'FAQ' },
].map(({ href, label }) => (
<li key={href}>
<NavigationMenuLink asChild>
<Link
href={href}
className="block py-1.5 text-xs text-foreground-light hover:text-foreground"
>
{label}
</Link>
</NavigationMenuLink>
</li>
))}
</ul>
</div>
{libraryCategories.map((category) => {
const blocks = libraryBlocks.filter(
(block) => block.category === category.name
)
return (
<TabsContent
key={category.name}
value={category.name}
className="m-0 min-w-0 flex-1 p-6"
>
{blocks.length > 0 ? (
<ul className="flex flex-col gap-4">
{blocks.map((block) => (
<li key={block.slug}>
<NavigationMenuLink asChild>
<Link
href={getLibraryBlockHref(block, framework)}
className="group/menu-item flex h-fit flex-col gap-1 rounded-md text-sm text-foreground-light hover:text-foreground select-none leading-none no-underline focus-ring focus-visible:text-foreground"
>
<span className="flex items-center gap-1">
<span className="text-sm leading-snug text-foreground">
{block.title}
</span>
<ChevronRight
strokeWidth={2}
className="h-3 w-3 text-foreground transition-all -translate-x-1 opacity-0 group-hover/menu-item:translate-x-0 group-hover/menu-item:opacity-100 motion-reduce:transition-none motion-reduce:translate-x-0"
/>
</span>
<span className="text-xs leading-snug text-foreground-lighter group-hover/menu-item:text-foreground-light group-focus-visible/menu-item:text-foreground-light">
{block.description}
</span>
</Link>
</NavigationMenuLink>
</li>
))}
</ul>
) : (
<p className="text-base text-foreground-light">
No blocks in this category yet.
</p>
)}
</TabsContent>
)
})}
</Tabs>
</NavigationMenuContent>
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>
</nav>
{/* Below md the centered nav is hidden, so search can take the free space. */}
<div className="flex min-w-0 flex-1 items-center justify-end gap-2 md:flex-none">
<div className="min-w-0 max-w-48 flex-1 md:w-28 md:flex-none lg:w-48">
<CommandMenu />
</div>
<Button
asChild
variant="text"
size="tiny"
className="hidden h-8 w-8 p-0 text-muted-foreground hover:text-foreground sm:inline-flex"
aria-label="View source on GitHub"
>
<a href="https://github.com/supabase/supabase/tree/master/apps/ui-library">
<Code2 size={16} />
</a>
</Button>
<Button
asChild
variant="text"
size="small"
className="hidden h-8 px-3 text-sm font-medium text-muted-foreground hover:text-foreground sm:inline-flex"
iconRight={<ArrowUpRight size={14} />}
>
<a href="https://supabase.com/docs">Docs</a>
</Button>
<ThemeSwitcherDropdown />
<Sidebar />
</div>
</div>
</header>
)
}