mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
## 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>
136 lines
5.0 KiB
TypeScript
136 lines
5.0 KiB
TypeScript
'use client'
|
|
|
|
import { LaptopIcon, MoonIcon, SunIcon } from 'lucide-react'
|
|
import { useTheme } from 'next-themes'
|
|
import { useRouter } from 'next/navigation'
|
|
import * as React from 'react'
|
|
import {
|
|
Button,
|
|
CommandDialog,
|
|
CommandEmpty,
|
|
CommandGroup,
|
|
CommandInput,
|
|
CommandItem,
|
|
CommandList,
|
|
CommandSeparator,
|
|
DialogDescription,
|
|
DialogProps,
|
|
DialogTitle,
|
|
} from 'ui'
|
|
|
|
import { gettingStarted } from '@/config/docs'
|
|
import { getLibraryBlockHref, libraryBlocks, libraryCategories } from '@/config/library'
|
|
import { useFramework } from '@/context/framework-context'
|
|
import { cn } from '@/lib/utils'
|
|
|
|
export function CommandMenu({ ...props }: DialogProps) {
|
|
const router = useRouter()
|
|
const { framework } = useFramework()
|
|
const [open, setOpen] = React.useState(false)
|
|
const { setTheme } = useTheme()
|
|
|
|
React.useEffect(() => {
|
|
const down = (e: KeyboardEvent) => {
|
|
if ((e.key === 'k' && (e.metaKey || e.ctrlKey)) || e.key === '/') {
|
|
if (
|
|
(e.target instanceof HTMLElement && e.target.isContentEditable) ||
|
|
e.target instanceof HTMLInputElement ||
|
|
e.target instanceof HTMLTextAreaElement ||
|
|
e.target instanceof HTMLSelectElement
|
|
) {
|
|
return
|
|
}
|
|
|
|
e.preventDefault()
|
|
setOpen((open) => !open)
|
|
}
|
|
}
|
|
|
|
document.addEventListener('keydown', down)
|
|
return () => document.removeEventListener('keydown', down)
|
|
}, [])
|
|
|
|
const runCommand = React.useCallback((command: () => unknown) => {
|
|
setOpen(false)
|
|
command()
|
|
}, [])
|
|
|
|
return (
|
|
<>
|
|
<Button
|
|
variant="outline"
|
|
className={cn(
|
|
`@container relative h-8 w-full justify-start rounded-[0.5rem] bg-background text-sm font-normal text-foreground-muted shadow-none sm:pr-12 md:pr-2.5 lg:pr-12
|
|
hover:border-foreground-muted hover:bg-surface-100 hover:text-foreground-lighter
|
|
`
|
|
)}
|
|
onClick={() => setOpen(true)}
|
|
{...props}
|
|
>
|
|
<span className="hidden @min-[7.5rem]:inline-flex">Search library...</span>
|
|
<span className="inline-flex @min-[7.5rem]:hidden">Search...</span>
|
|
<kbd className="pointer-events-none absolute right-[0.3rem] top-[0.3rem] hidden h-5 select-none items-center gap-1 rounded-sm border bg-surface-200 px-1.5 font-mono text-[10px] font-medium opacity-100 sm:flex md:hidden lg:flex text-foreground-light">
|
|
<span className="text-sm">⌘</span>K
|
|
</kbd>
|
|
</Button>
|
|
<CommandDialog open={open} onOpenChange={setOpen}>
|
|
<DialogTitle className="sr-only">Search the library</DialogTitle>
|
|
<DialogDescription className="sr-only">
|
|
Find guides, blocks, starter apps, and theme settings.
|
|
</DialogDescription>
|
|
<CommandInput placeholder="Type a command or search..." />
|
|
<CommandList className="min-h-0 max-h-[min(400px,calc(100dvh-8rem))] overscroll-contain [&_[cmdk-group]]:p-2! [&_[cmdk-item]]:rounded-md [&_[cmdk-item]]:p-2!">
|
|
<CommandEmpty>No results found.</CommandEmpty>
|
|
<CommandGroup key="pages" heading="Pages">
|
|
{gettingStarted.items.map((navItem) => (
|
|
<CommandItem
|
|
key={navItem.href}
|
|
value={navItem.title}
|
|
onSelect={() => runCommand(() => router.push(navItem.href as string))}
|
|
>
|
|
{navItem.title}
|
|
</CommandItem>
|
|
))}
|
|
</CommandGroup>
|
|
{libraryCategories.map((category) => (
|
|
<CommandGroup key={category.slug} heading={category.name}>
|
|
{libraryBlocks
|
|
.filter((block) => block.category === category.name)
|
|
.map((block) => (
|
|
<CommandItem
|
|
key={block.slug}
|
|
value={`${block.title} ${block.category} ${block.tags.join(' ')}`}
|
|
onSelect={() =>
|
|
runCommand(() => {
|
|
const href = getLibraryBlockHref(block, framework)
|
|
if (block.external) window.location.assign(href)
|
|
else router.push(href)
|
|
})
|
|
}
|
|
>
|
|
{block.title}
|
|
</CommandItem>
|
|
))}
|
|
</CommandGroup>
|
|
))}
|
|
<CommandSeparator />
|
|
<CommandGroup heading="Theme">
|
|
<CommandItem onSelect={() => runCommand(() => setTheme('light'))}>
|
|
<SunIcon className="mr-2 h-4 w-4" strokeWidth={1} />
|
|
Light
|
|
</CommandItem>
|
|
<CommandItem onSelect={() => runCommand(() => setTheme('dark'))}>
|
|
<MoonIcon className="mr-2 h-4 w-4" strokeWidth={1} />
|
|
Dark
|
|
</CommandItem>
|
|
<CommandItem onSelect={() => runCommand(() => setTheme('system'))}>
|
|
<LaptopIcon className="mr-2 h-4 w-4" strokeWidth={1} />
|
|
System
|
|
</CommandItem>
|
|
</CommandGroup>
|
|
</CommandList>
|
|
</CommandDialog>
|
|
</>
|
|
)
|
|
}
|