import clsx from 'clsx'; import { cva, type VariantProps } from 'class-variance-authority'; import { ComponentType, PropsWithChildren, ReactNode } from 'react'; import { Icon } from '@@/Icon'; const cardContainer = cva( [ 'overflow-hidden border border-solid border-gray-5', 'th-highcontrast:border-white', 'th-dark:border-legacy-grey-3', ], { variants: { variant: { default: [ 'rounded-xl bg-white', 'th-highcontrast:bg-black', 'th-dark:bg-gray-iron-11', ], filled: [ 'rounded-lg bg-gray-neutral-3', 'th-highcontrast:bg-gray-warm-10', 'th-dark:bg-gray-iron-10', ], }, shadow: { true: 'shadow-md', }, }, defaultVariants: { variant: 'default', }, } ); export type CardVariant = NonNullable< VariantProps['variant'] >; /** * Low-level card surface. Compose with `Card.Header` for a titled section and `Card.Body` for * padded content. Use `variant="filled"` for a gray background. * Reach for `Widget` when you need a full dashboard panel with toolbar. * * @example * * * Manage pull-through caching and credentials. * */ export const Card = { Container: CardContainer, Header: CardHeader, Body: CardBody, }; interface CardContainerProps extends VariantProps { className?: string; 'aria-label'?: string; } function CardContainer({ className, children, shadow, variant, 'aria-label': ariaLabel, }: PropsWithChildren) { return (
{children}
); } interface CardBodyProps { className?: string; } function CardBody({ className, children }: PropsWithChildren) { return
{children}
; } interface CardHeaderProps { title: ReactNode; subtitle?: ReactNode; icon?: ComponentType; actions?: ReactNode; } function CardHeader({ title, subtitle, icon, actions }: CardHeaderProps) { return (
{icon && ( )} {title}
{subtitle && ( {subtitle} )}
{actions && (
{actions}
)}
); }