/** * Card — a content surface. * * ```tsx * * * Living room sofa * Three seats, oat linen * * * * * * ``` * * All the padding lives on the slots and none of it on the root, which is why * a card whose media reaches its own corners needs nothing but * `overflow-hidden`. * * Every part is a plain view: the card draws a surface and gets out of the way, * and nothing here reaches for an animation driver or a native module. A card * that wants a decorative backing layer composes one as its first child. */ import { forwardRef } from 'react'; import { View, type ViewProps } from 'react-native'; import { tv, type VariantProps } from 'tailwind-variants'; import { cn } from '../../utils/cn'; import { Text, type TextProps } from '../../primitives/text'; const footerVariants = tv({ base: 'flex-row items-center gap-2', variants: { /** * Whether the footer draws a surface of its own. * * `plain` is part of the card: same background, padding continuing from the * content above it. `panel` is a band set into it — a rule across the top, * a step darker, and the card's own bottom corners — so the buttons read as * the card's actions rather than as the last thing in its body. Use it when * the footer is what somebody does with the card, not more of what it says. */ variant: { plain: 'p-6 pt-0', panel: 'rounded-b-2xl border-t border-border bg-inset p-6', }, }, defaultVariants: { variant: 'plain', }, }); export interface CardProps extends ViewProps { className?: string; } export interface CardFooterProps extends CardProps, VariantProps {} const CardRoot = forwardRef(({ className, ...props }, ref) => ( )); CardRoot.displayName = 'Card'; const CardHeader = forwardRef(({ className, ...props }, ref) => ( )); CardHeader.displayName = 'Card.Header'; const CardTitle = forwardRef, TextProps>( ({ className, ...props }, ref) => ( ) ); CardTitle.displayName = 'Card.Title'; const CardDescription = forwardRef, TextProps>( ({ className, ...props }, ref) => ( ) ); CardDescription.displayName = 'Card.Description'; const CardContent = forwardRef(({ className, ...props }, ref) => ( )); CardContent.displayName = 'Card.Content'; const CardFooter = forwardRef( ({ className, variant, ...props }, ref) => ( ) ); CardFooter.displayName = 'Card.Footer'; export const Card = Object.assign(CardRoot, { Header: CardHeader, Title: CardTitle, Description: CardDescription, Content: CardContent, Footer: CardFooter, });