Skip to content

Commit 871a87b

Browse files
feat: add "New" badge to category cards for new pages
1 parent d27e2b0 commit 871a87b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

apps/ui/app/page.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import type { Metadata } from "next";
88
import Link from "next/link";
99
import { getCategoryThumbnail } from "@/components/category-thumbnails";
1010
import { categories } from "@/config/categories";
11+
import { PAGES_NEW } from "@/lib/docs";
12+
import { Badge } from "@/registry/default/ui/badge";
1113
import { Button } from "@/registry/default/ui/button";
1214
import {
1315
Card,
@@ -88,6 +90,7 @@ function CategoryCard({
8890
thumbnail,
8991
}: CategoryCardProps) {
9092
const href = `/docs/components/${slug}`;
93+
const isNew = PAGES_NEW.includes(href);
9194

9295
return (
9396
<CardFrame className="after:-inset-[5px] after:-z-1 w-full after:pointer-events-none after:absolute after:rounded-[calc(var(--radius-xl)+4px)] after:border after:border-border/64">
@@ -110,6 +113,11 @@ function CategoryCard({
110113
</CardFrameDescription>
111114
</CardFrameHeader>
112115
<Card className="pointer-events-none min-h-55 flex-1 flex-col flex-wrap overflow-x-auto bg-[color-mix(in_srgb,var(--color-card),var(--color-sidebar))] dark:bg-background">
116+
{isNew && (
117+
<Badge className="absolute end-3 top-3" variant="info">
118+
New
119+
</Badge>
120+
)}
113121
<CardPanel className="flex flex-1 items-center justify-center px-8 [--border:--alpha(var(--color-black)/7%)] [--btn-from:--alpha(var(--color-primary)/90%)] [--btn-to:var(--color-primary)] in-[[data-slot=card-frame]:has(a:not(:hover))]:*:translate-y-0.5 *:transition-transform *:duration-200 dark:[--border:--alpha(var(--color-white)/3%)] dark:[--btn-from:var(--color-primary)] dark:[--btn-to:--alpha(var(--color-primary)/90%)]">
114122
{thumbnail}
115123
</CardPanel>

0 commit comments

Comments
 (0)