mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 09:55:06 +03:00
## What kind of change does this PR introduce? Bug fix, docs update ## What is the current behavior? - The breadcrumb component docs at `/design-system/docs/components/breadcrumb` reference six `ComponentPreview` demos, but the example components were never implemented and their registry entries were commented out. The page rendered without working previews. Unrelated but snuck in: - The “responsive” Admonition example is a H2 instead of H3 like the others. - The design system ⌘K command switcher grows to the full height of its nav items instead of scrolling within a bounded list. Closes DEPR-607 Closes DEPR-608 ## What is the new behavior? - Adds six breadcrumb example components (`breadcrumb-demo`, `breadcrumb-separator`, `breadcrumb-dropdown`, `breadcrumb-ellipsis`, `breadcrumb-link`, `breadcrumb-responsive`) under `apps/design-system/registry/default/example/` - Re-enables the corresponding entries in `registry/examples.ts` and rebuilds `__registry__/index.tsx` - Fixes invalid nested `<li>` markup in the responsive breadcrumb demo that caused a hydration error Also includes two small unrelated fixes: - Caps the ⌘K switcher `CommandList` at `max-h-[300px]` so it scrolls instead of stretching - Corrects the admonition fragment docs header type ## Additional context Test plan: - [ ] Run `pnpm dev:design-system` and open `/docs/components/breadcrumb` - [ ] Confirm all six breadcrumb previews render - [ ] Confirm no hydration warnings in the browser console for the responsive example - [ ] Open the ⌘K switcher and confirm the list scrolls within a bounded height <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added multiple Breadcrumb demos to the design system gallery, including link, dropdown, ellipsis, separator, and responsive variants. * Enabled these Breadcrumb demos in the examples registry. * **Documentation** * Updated the “Responsive” docs heading level. * **Style** * Constrained the command menu list height inside the dialog for improved fit. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
138 lines
4.3 KiB
TypeScript
138 lines
4.3 KiB
TypeScript
'use client'
|
|
|
|
import Link from 'next/link'
|
|
import * as React from 'react'
|
|
import {
|
|
Breadcrumb,
|
|
BreadcrumbEllipsis,
|
|
BreadcrumbItem,
|
|
BreadcrumbLink,
|
|
BreadcrumbList,
|
|
BreadcrumbPage,
|
|
BreadcrumbSeparator,
|
|
Button,
|
|
Drawer,
|
|
DrawerClose,
|
|
DrawerContent,
|
|
DrawerDescription,
|
|
DrawerFooter,
|
|
DrawerHeader,
|
|
DrawerTitle,
|
|
DrawerTrigger,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
} from 'ui'
|
|
|
|
function useMediaQuery(query: string) {
|
|
const [value, setValue] = React.useState(false)
|
|
|
|
React.useEffect(() => {
|
|
function onChange(event: MediaQueryListEvent) {
|
|
setValue(event.matches)
|
|
}
|
|
|
|
const result = matchMedia(query)
|
|
result.addEventListener('change', onChange)
|
|
setValue(result.matches)
|
|
|
|
return () => result.removeEventListener('change', onChange)
|
|
}, [query])
|
|
|
|
return value
|
|
}
|
|
|
|
const items = [
|
|
{ href: '#', label: 'Home' },
|
|
{ href: '#', label: 'Documentation' },
|
|
{ href: '#', label: 'Build Your Application' },
|
|
{ href: '#', label: 'Data Fetching' },
|
|
{ label: 'Caching and Revalidating' },
|
|
]
|
|
|
|
const ITEMS_TO_DISPLAY = 3
|
|
|
|
export default function BreadcrumbResponsiveDemo() {
|
|
const [open, setOpen] = React.useState(false)
|
|
const isDesktop = useMediaQuery('(min-width: 768px)')
|
|
|
|
return (
|
|
<Breadcrumb>
|
|
<BreadcrumbList>
|
|
<BreadcrumbItem>
|
|
<BreadcrumbLink asChild>
|
|
<Link href={items[0].href ?? '/'}>{items[0].label}</Link>
|
|
</BreadcrumbLink>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator />
|
|
{items.length > ITEMS_TO_DISPLAY ? (
|
|
<>
|
|
<BreadcrumbItem>
|
|
{isDesktop ? (
|
|
<DropdownMenu open={open} onOpenChange={setOpen}>
|
|
<DropdownMenuTrigger className="flex items-center gap-1" aria-label="Toggle menu">
|
|
<BreadcrumbEllipsis className="size-4" />
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="start">
|
|
{items.slice(1, -2).map((item, index) => (
|
|
<DropdownMenuItem key={index} asChild>
|
|
<Link href={item.href ? item.href : '#'}>{item.label}</Link>
|
|
</DropdownMenuItem>
|
|
))}
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
) : (
|
|
<Drawer open={open} onOpenChange={setOpen}>
|
|
<DrawerTrigger aria-label="Toggle Menu">
|
|
<BreadcrumbEllipsis className="h-4 w-4" />
|
|
</DrawerTrigger>
|
|
<DrawerContent>
|
|
<DrawerHeader className="text-left">
|
|
<DrawerTitle>Navigate to</DrawerTitle>
|
|
<DrawerDescription>Select a page to navigate to.</DrawerDescription>
|
|
</DrawerHeader>
|
|
<div className="grid gap-1 px-4">
|
|
{items.slice(1, -2).map((item, index) => (
|
|
<Link
|
|
key={index}
|
|
href={item.href ? item.href : '#'}
|
|
className="py-1 text-sm"
|
|
>
|
|
{item.label}
|
|
</Link>
|
|
))}
|
|
</div>
|
|
<DrawerFooter className="pt-4">
|
|
<DrawerClose asChild>
|
|
<Button variant="outline">Close</Button>
|
|
</DrawerClose>
|
|
</DrawerFooter>
|
|
</DrawerContent>
|
|
</Drawer>
|
|
)}
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator />
|
|
</>
|
|
) : null}
|
|
{items.slice(-ITEMS_TO_DISPLAY + 1).map((item, index) => (
|
|
<React.Fragment key={index}>
|
|
{index > 0 ? <BreadcrumbSeparator /> : null}
|
|
<BreadcrumbItem>
|
|
{item.href ? (
|
|
<BreadcrumbLink asChild className="max-w-20 truncate md:max-w-none">
|
|
<Link href={item.href}>{item.label}</Link>
|
|
</BreadcrumbLink>
|
|
) : (
|
|
<BreadcrumbPage className="max-w-20 truncate md:max-w-none">
|
|
{item.label}
|
|
</BreadcrumbPage>
|
|
)}
|
|
</BreadcrumbItem>
|
|
</React.Fragment>
|
|
))}
|
|
</BreadcrumbList>
|
|
</Breadcrumb>
|
|
)
|
|
}
|