| 1 | import * as React from "react"; |
| 2 | import { cn } |
| 3 | |
| 4 | function Card({ |
| 5 | className, |
| 6 | size = "default" |
| 7 | ...props |
| 8 | }: React. |
| 9 | return ( |
| 10 | <div |
| 11 | data-slot="card" |
| 12 | data-size={size} |
| 13 | className={cn( |
| 14 | "group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl", |
| 15 | className, |
| 16 | )} |
| 17 | {...props} |
| 18 | /> |
| 19 | ); |
| 20 | } |
| 21 | |
| 22 | function CardHeader({ className |
| 23 | return ( |
| 24 | <div |
| 25 | data-slot="card-header" |
| 26 | className={cn( |
| 27 | "group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)", |
| 28 | className, |
| 29 | )} |
| 30 | {...props} |
| 31 | /> |
| 32 | ); |
| 33 | } |
| 34 | |
| 35 | function CardTitle({ className |
| 36 | return ( |
| 37 | <div |
| 38 | data-slot="card-title" |
| 39 | className={cn( |
| 40 | "font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm", |
| 41 | className, |
| 42 | )} |
| 43 | {...props} |
| 44 | /> |
| 45 | ); |
| 46 | } |
| 47 | |
| 48 | function CardDescription({ className |
| 49 | return ( |
| 50 | <div |
| 51 | data-slot="card-description" |
| 52 | className={cn(" |
| 53 | {...props} |
| 54 | /> |
| 55 | ); |
| 56 | } |
| 57 | |
| 58 | function CardAction({ className |
| 59 | return ( |
| 60 | <div |
| 61 | data-slot="card-action" |
| 62 | className={cn( |
| 63 | "col-start-2 row-span-2 row-start-1 self-start justify-self-end", |
| 64 | className, |
| 65 | )} |
| 66 | {...props} |
| 67 | /> |
| 68 | ); |
| 69 | } |
| 70 | |
| 71 | function CardContent({ className |
| 72 | return ( |
| 73 | <div |
| 74 | data-slot="card-content" |
| 75 | className={cn(" |
| 76 | {...props} |
| 77 | /> |
| 78 | ); |
| 79 | } |
| 80 | |
| 81 | function CardFooter({ className |
| 82 | return ( |
| 83 | <div |
| 84 | data-slot="card-footer" |
| 85 | className={cn( |
| 86 | "flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)", |
| 87 | className, |
| 88 | )} |
| 89 | {...props} |
| 90 | /> |
| 91 | ); |
| 92 | } |
| 93 | |
| 94 | export { |
| 95 | Card, |
| 96 | CardHeader, |
| 97 | CardFooter, |
| 98 | CardTitle, |
| 99 | CardAction, |
| 100 | CardDescription, |
| 101 | CardContent, |
| 102 | }; |