Skip to documentation
Design system / Sources & standards
Current repository source
content-cards.tsx
src/components/editorial/content-cards.tsx
This view contains the escaped source read during the deployment build. Code and policy text are unchanged. Markdown is shown as source, not rendered as a document. A new deployment refreshes the content.
import Link from "next/link";
import type { ComponentProps, ReactNode } from "react";
import { Card, CardContent, CardHeader } from "@/components/ui/card";
import { Text } from "@/components/ui/text";
import { cn } from "@/lib/utils";
export type ContentCardItem = {
id: string;
title: string;
description: string;
href?: string;
preview?: ReactNode;
meta?: ReactNode;
};
/** Molecule: a collection of concepts or visual catalogue entries. Preview is
* a sibling of the title link, never nested inside an interactive anchor. */
export function ContentCards({
items,
level = 3,
className,
...props
}: Omit<ComponentProps<"div">, "children"> & {
items: readonly ContentCardItem[];
level?: 2 | 3 | 4;
}) {
const Heading = `h${level}` as "h2" | "h3" | "h4";
return (
<div
{...props}
data-slot="content-cards"
className={cn("grid gap-6 sm:grid-cols-2", className)}
>
{items.map((item) => (
<Card key={item.id} elevation="flat" className="min-w-0">
<CardHeader>
<Heading className="min-w-0 break-words text-title font-semibold">
{item.href ? (
<Link
href={item.href}
className="underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
>
{item.title}
</Link>
) : (
item.title
)}
</Heading>
</CardHeader>
<CardContent className="space-y-4">
{item.preview}
<Text rhythm="loose" className="break-words text-text-muted">
{item.description}
</Text>
{item.meta}
</CardContent>
</Card>
))}
</div>
);
}
All sources and standards