Files
shadcn-ui/apps/v4/components/blocks-nav.tsx
shadcn 84bd724d97 feat: refactor registry (#8598)
* feat: refactor registry

* fix: remove components

* refactor: getActiveStyle

* fix: prettier in build-registry

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* fix

* Update apps/v4/scripts/build-registry.mts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix

* Update apps/v4/scripts/build-registry.mts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update apps/v4/components/block-viewer.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-29 15:07:56 +04:00

56 lines
1.4 KiB
TypeScript

"use client"
import Link from "next/link"
import { usePathname } from "next/navigation"
import { registryCategories } from "@/lib/categories"
import { ScrollArea, ScrollBar } from "@/registry/new-york-v4/ui/scroll-area"
export function BlocksNav() {
const pathname = usePathname()
return (
<div className="relative overflow-hidden">
<ScrollArea className="max-w-none">
<div className="flex items-center">
<BlocksNavLink
category={{ name: "Featured", slug: "", hidden: false }}
isActive={pathname === "/blocks"}
/>
{registryCategories.map((category) => (
<BlocksNavLink
key={category.slug}
category={category}
isActive={pathname === `/blocks/${category.slug}`}
/>
))}
</div>
<ScrollBar orientation="horizontal" className="invisible" />
</ScrollArea>
</div>
)
}
function BlocksNavLink({
category,
isActive,
}: {
category: (typeof registryCategories)[number]
isActive: boolean
}) {
if (category.hidden) {
return null
}
return (
<Link
href={`/blocks/${category.slug}`}
key={category.slug}
className="text-muted-foreground hover:text-primary data-[active=true]:text-primary flex h-7 items-center justify-center px-4 text-center text-base font-medium transition-colors"
data-active={isActive}
>
{category.name}
</Link>
)
}