import { forwardRef, type HTMLAttributes, type ReactNode } from 'react'; import { cn } from '../../lib/cn'; import { Card as UiCard, CardAction, CardDescription, CardFooter as UiCardFooter, CardHeader as UiCardHeader, CardTitle, } from '../ui/card'; import { CountBadge } from '../Badge/Badge'; export interface CardProps extends HTMLAttributes { /** Element to render as; `section` for dashboard panels, `article` for group cards. */ as?: 'div' | 'section' | 'article' | 'form' | 'aside'; /** Inner padding. `none` lets rows run edge to edge (settings, task list). */ padding?: 'none' | 'sm' | 'md'; /** Classes for the inner surface. */ innerClassName?: string; } /** * The design's signature double frame: a dark 5px rim around a raised surface. * Use it for dashboard panels, settings sections, auth forms and group cards. */ export const Card = forwardRef(function Card( { as: Tag = 'section', padding = 'md', className, innerClassName, children, ...props }, ref, ) { return ( {children} ); }); export interface CardHeaderProps extends Omit, 'title'> { title: ReactNode; /** id for the heading, so the card can be `aria-labelledby` it. */ titleId?: string; count?: ReactNode; /** Secondary line under the title. */ subtitle?: ReactNode; /** Right side: filters, "more" button, add button. */ actions?: ReactNode; /** Heading level. */ level?: 2 | 3; } export function CardHeader({ title, titleId, count, subtitle, actions, level = 2, ...props }: CardHeaderProps) { const H = level === 2 ? 'h2' : 'h3'; return ( {title} {count !== undefined && {count}} {subtitle && {subtitle}} {actions && {actions}} ); } /** Footer row that pins its content to the bottom of a card. */ export const CardFooter = UiCardFooter;