xonecas.io
556
Bn

bees-nest / files

bees-nest / src / components / ui / card.tsx

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