-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcard.tsx
More file actions
171 lines (160 loc) · 4.44 KB
/
Copy pathcard.tsx
File metadata and controls
171 lines (160 loc) · 4.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import type * as React from "react";
import { cn } from "@/shared/lib/cn";
import { getDesignSystemMetadata } from "@/shared/ui/design-system/metadata";
function Card({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
{...getDesignSystemMetadata({
component: "Card",
slot: "card",
source: "src/shared/ui/card.tsx",
customClassName: typeof className === "string" ? className : undefined,
})}
data-slot="card"
className={cn(
"flex flex-col gap-6 rounded-md border border-border bg-card py-6 text-card-foreground",
className,
)}
{...props}
/>
);
}
interface ExpandableCardProps extends React.ComponentProps<"div"> {
interactive?: boolean;
}
/**
* Compact settings-style card for surfaces that expand in place.
* Use for row/card hybrids whose collapsed state is the primary control.
*/
function ExpandableCard({
interactive = false,
className,
...props
}: ExpandableCardProps) {
return (
<div
{...getDesignSystemMetadata({
component: "Card",
slot: "expandable-card",
source: "src/shared/ui/card.tsx",
customClassName: typeof className === "string" ? className : undefined,
})}
data-slot="expandable-card"
className={cn(
"flex flex-col rounded-md bg-muted p-3 text-foreground",
interactive && "cursor-pointer",
className,
)}
{...props}
/>
);
}
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
{...getDesignSystemMetadata({
component: "Card",
slot: "card-header",
source: "src/shared/ui/card.tsx",
customClassName: typeof className === "string" ? className : undefined,
})}
data-slot="card-header"
className={cn(
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
className,
)}
{...props}
/>
);
}
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
{...getDesignSystemMetadata({
component: "Card",
slot: "card-title",
source: "src/shared/ui/card.tsx",
customClassName: typeof className === "string" ? className : undefined,
})}
data-slot="card-title"
className={cn(
"font-display font-semibold leading-none tracking-[-0.01em]",
className,
)}
{...props}
/>
);
}
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
{...getDesignSystemMetadata({
component: "Card",
slot: "card-description",
source: "src/shared/ui/card.tsx",
customClassName: typeof className === "string" ? className : undefined,
})}
data-slot="card-description"
className={cn("text-muted-foreground text-sm", className)}
{...props}
/>
);
}
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
{...getDesignSystemMetadata({
component: "Card",
slot: "card-action",
source: "src/shared/ui/card.tsx",
customClassName: typeof className === "string" ? className : undefined,
})}
data-slot="card-action"
className={cn(
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
className,
)}
{...props}
/>
);
}
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
{...getDesignSystemMetadata({
component: "Card",
slot: "card-content",
source: "src/shared/ui/card.tsx",
customClassName: typeof className === "string" ? className : undefined,
})}
data-slot="card-content"
className={cn("px-6", className)}
{...props}
/>
);
}
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
{...getDesignSystemMetadata({
component: "Card",
slot: "card-footer",
source: "src/shared/ui/card.tsx",
customClassName: typeof className === "string" ? className : undefined,
})}
data-slot="card-footer"
className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
{...props}
/>
);
}
export {
Card,
ExpandableCard,
CardHeader,
CardFooter,
CardTitle,
CardAction,
CardDescription,
CardContent,
};