mirror of
https://github.com/supabase/supabase.git
synced 2026-09-08 19:08:44 +08:00
Our UI Library registry is expanding to include blocks that go beyond UI and in some cases focus purely on back-end. This PR is a precursor to adding more back-end related blocks. This PR includes the `ui-library -> library` rename plus redirects and small UI copy updates. Since this is a rename we'll need to update Vercel configuration. ## Vercel rollout Keep the Library project Root Directory as `apps/ui-library` 1. In the **Library** Vercel project, set: `NEXT_PUBLIC_BASE_PATH=/library` Apply it to Preview and Production, then redeploy the Library project. 2. In the **www** Vercel project, add: `NEXT_PUBLIC_LIBRARY_URL=<current value of NEXT_PUBLIC_UI_LIBRARY_URL>` Apply it to Preview and Production. Keep `NEXT_PUBLIC_UI_LIBRARY_URL` during the migration, then redeploy the www project. 3. Deploy in this order: 1. Library project 2. www project 4. Validate: - `/library` - `/library/docs/nextjs/password-based-auth` - `/ui` redirects to `/library` - `/ui/docs/nextjs/password-based-auth` redirects to `/library/docs/nextjs/password-based-auth` - `/ui/docs/ai-editors-rules/*` still uses its existing Docs redirects No Vercel dashboard redirect rules are needed. Environment-variable changes require a new deployment. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Supabase UI Library has been renamed to **Supabase Library** across navigation, pages, documentation, and resource links. * The Library is now available at `/library`, with updated descriptions covering components, blocks, and developer tools. * **Bug Fixes** * Added permanent redirects from legacy `/ui` URLs to corresponding `/library` paths. * Updated links throughout the site and documentation to prevent broken navigation and references. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
113 lines
3.8 KiB
TypeScript
113 lines
3.8 KiB
TypeScript
'use client'
|
|
|
|
import { CircleIcon, 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,
|
|
DialogProps,
|
|
} from 'ui'
|
|
|
|
import { COMMAND_ITEMS } from '@/config/docs'
|
|
import { cn } from '@/lib/utils'
|
|
|
|
export function CommandMenu({ ...props }: DialogProps) {
|
|
const router = useRouter()
|
|
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(
|
|
`relative h-8 w-full justify-start rounded-[0.5rem] bg-background text-sm font-normal text-foreground-muted shadow-none sm:pr-12
|
|
hover:border-foreground-muted hover:bg-surface-100 hover:text-foreground-lighter
|
|
`
|
|
)}
|
|
onClick={() => setOpen(true)}
|
|
{...props}
|
|
>
|
|
<span className="hidden lg:inline-flex">Search Library...</span>
|
|
<span className="inline-flex lg: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 text-foreground-light">
|
|
<span className="text-sm">⌘</span>K
|
|
</kbd>
|
|
</Button>
|
|
<CommandDialog open={open} onOpenChange={setOpen}>
|
|
<CommandInput placeholder="Type a command or search..." />
|
|
<CommandList>
|
|
<CommandEmpty>No results found.</CommandEmpty>
|
|
<CommandGroup key="pages" heading="Pages">
|
|
{COMMAND_ITEMS.map((navItem) => (
|
|
<CommandItem
|
|
key={navItem.href}
|
|
value={navItem.label}
|
|
onSelect={() => runCommand(() => router.push(navItem.href as string))}
|
|
>
|
|
<div className="mr-2 flex h-4 w-4 items-center justify-center">
|
|
<CircleIcon className="h-3 w-3" strokeWidth={1} />
|
|
</div>
|
|
{navItem.label}
|
|
</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('classic-dark'))}>
|
|
<MoonIcon className="mr-2 h-4 w-4" strokeWidth={1} />
|
|
Classic dark
|
|
</CommandItem>
|
|
<CommandItem onSelect={() => runCommand(() => setTheme('system'))}>
|
|
<LaptopIcon className="mr-2 h-4 w-4" strokeWidth={1} />
|
|
System
|
|
</CommandItem>
|
|
</CommandGroup>
|
|
</CommandList>
|
|
</CommandDialog>
|
|
</>
|
|
)
|
|
}
|