import { cva, type VariantProps } from "class-variance-authority"; import { ChevronDown, ChevronUp } from "lucide-react"; import { type ComponentProps, type ReactNode, useState } from "react"; import { cn } from "../hooks"; import { Button } from "./button"; /** * Variants for the card component. */ const cardVariants = cva( [ "relative", "flex", "flex-col", "rounded-uk-xl", "bg-bg-primary", "liquid-dark:liquid-dark-bg", "liquid-light:liquid-light-bg", ], { variants: { size: { sm: "p-sm", md: "p-md", lg: "p-lg", xl: "p-xl", }, }, defaultVariants: { size: "lg", }, }, ); export interface CardProps extends ComponentProps<"div">, VariantProps { /** * Enable collapse/expand functionality */ collapsible?: boolean; /** * Content to display when card is collapsed (typically a label or title) */ collapsedContent?: ReactNode; /** * Initially collapsed state (only used when collapsible is true) */ defaultCollapsed?: boolean; } /** * Container card with default padding, radius and shadow. */ function Card({ className, size, collapsible, collapsedContent, defaultCollapsed = false, children, ...props }: CardProps) { const [isCollapsed, setIsCollapsed] = useState(defaultCollapsed); if (collapsible) { if (isCollapsed) { return (
{collapsedContent}
); } return (
{children}
); } return (
{children}
); } /** * Variants for the card header component. */ const cardHeaderVariants = cva(["flex", "flex-row", "items-center", "justify-between"], { variants: { size: { sm: "gap-sm", md: "gap-md", lg: "gap-lg", xl: "gap-xl", }, }, defaultVariants: { size: "lg", }, }); export interface CardHeaderProps extends ComponentProps<"div">, VariantProps {} /** * Horizontal header row for card. */ function CardHeader({ className, size, ...props }: CardHeaderProps) { return (
); } /** * Title text styling within card. */ function CardTitle({ className, ...props }: ComponentProps<"div">) { return (
); } /** * Secondary description text. */ function CardDescription({ className, ...props }: ComponentProps<"div">) { return (
); } /** * Right-aligned action area. */ function CardAction({ className, ...props }: ComponentProps<"div">) { return (
); } /** * Main content area. */ function CardContent({ className, ...props }: ComponentProps<"div">) { return
; } /** * Footer row for actions or meta. */ function CardFooter({ className, ...props }: ComponentProps<"div">) { return
; } export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent };