|
| 1 | +import { cn } from "@/lib/utils"; |
| 2 | +import { forwardRef, HTMLAttributes } from "react"; |
| 3 | + |
| 4 | +interface AlternateCardProps extends HTMLAttributes<HTMLDivElement> { |
| 5 | + alternate?: boolean; |
| 6 | +} |
| 7 | + |
| 8 | +const Card = forwardRef<HTMLDivElement, AlternateCardProps>( |
| 9 | + ({ className, alternate, ...props }, ref) => ( |
| 10 | + <div |
| 11 | + ref={ref} |
| 12 | + className={cn( |
| 13 | + "rounded-lg border-none text-card-foreground shadow-f-card bg-white", |
| 14 | + { "bg-background shadow-f-card-inset": alternate }, |
| 15 | + className |
| 16 | + )} |
| 17 | + {...props} |
| 18 | + /> |
| 19 | + ) |
| 20 | +); |
| 21 | +Card.displayName = "Card"; |
| 22 | + |
| 23 | +const CardHeader = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>( |
| 24 | + ({ className, ...props }, ref) => ( |
| 25 | + <div ref={ref} className={cn("p-6 w-full", className)} {...props} /> |
| 26 | + ) |
| 27 | +); |
| 28 | +CardHeader.displayName = "CardHeader"; |
| 29 | + |
| 30 | +const CardTitle = forwardRef< |
| 31 | + HTMLParagraphElement, |
| 32 | + HTMLAttributes<HTMLHeadingElement> |
| 33 | +>(({ className, ...props }, ref) => ( |
| 34 | + <h3 |
| 35 | + ref={ref} |
| 36 | + className={cn( |
| 37 | + "text-lg font-semibold leading-none tracking-tight text-primary", |
| 38 | + className |
| 39 | + )} |
| 40 | + {...props} |
| 41 | + /> |
| 42 | +)); |
| 43 | +CardTitle.displayName = "CardTitle"; |
| 44 | + |
| 45 | +const CardDescription = forwardRef< |
| 46 | + HTMLParagraphElement, |
| 47 | + HTMLAttributes<HTMLParagraphElement> |
| 48 | +>(({ className, ...props }, ref) => ( |
| 49 | + <p |
| 50 | + ref={ref} |
| 51 | + className={cn("text-sm text-muted-foreground", className)} |
| 52 | + {...props} |
| 53 | + /> |
| 54 | +)); |
| 55 | +CardDescription.displayName = "CardDescription"; |
| 56 | + |
| 57 | +const CardContent = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>( |
| 58 | + ({ className, ...props }, ref) => ( |
| 59 | + <div ref={ref} className={cn("p-6 pt-0", className)} {...props} /> |
| 60 | + ) |
| 61 | +); |
| 62 | +CardContent.displayName = "CardContent"; |
| 63 | + |
| 64 | +const CardFooter = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>( |
| 65 | + ({ className, ...props }, ref) => ( |
| 66 | + <div |
| 67 | + ref={ref} |
| 68 | + className={cn("flex items-center p-6 pt-0", className)} |
| 69 | + {...props} |
| 70 | + /> |
| 71 | + ) |
| 72 | +); |
| 73 | +CardFooter.displayName = "CardFooter"; |
| 74 | + |
| 75 | +export { |
| 76 | + Card, |
| 77 | + CardHeader, |
| 78 | + CardFooter, |
| 79 | + CardTitle, |
| 80 | + CardDescription, |
| 81 | + CardContent, |
| 82 | +}; |
0 commit comments