|
1 | | -"use client"; |
2 | | - |
3 | | -import { mergeProps } from "@base-ui/react/merge-props"; |
4 | | -import { useRender } from "@base-ui/react/use-render"; |
| 1 | +import * as React from "react"; |
5 | 2 |
|
6 | 3 | import { cn } from "~/lib/utils"; |
7 | 4 |
|
8 | | -function Card({ className, render, ...props }: useRender.ComponentProps<"div">) { |
9 | | - const defaultProps = { |
10 | | - className: cn( |
11 | | - "relative flex flex-col rounded-2xl border bg-card not-dark:bg-clip-padding text-card-foreground shadow-xs/5 before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-2xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:before:shadow-[0_-1px_--theme(--color-white/6%)]", |
12 | | - className, |
13 | | - ), |
14 | | - "data-slot": "card", |
15 | | - }; |
16 | | - |
17 | | - return useRender({ |
18 | | - defaultTagName: "div", |
19 | | - props: mergeProps<"div">(defaultProps, props), |
20 | | - render, |
21 | | - }); |
22 | | -} |
23 | | - |
24 | | -function CardFrame({ className, render, ...props }: useRender.ComponentProps<"div">) { |
25 | | - const defaultProps = { |
26 | | - className: cn( |
27 | | - "[--clip-top:-1rem] [--clip-bottom:-1rem] *:data-[slot=card]:first:[--clip-top:1px] *:data-[slot=card]:last:[--clip-bottom:1px] flex flex-col relative rounded-2xl border bg-card before:bg-muted/72 not-dark:bg-clip-padding text-card-foreground shadow-xs/5 before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-2xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:before:shadow-[0_-1px_--theme(--color-white/6%)] *:data-[slot=card]:-m-px *:not-last:data-[slot=card]:rounded-b-xl *:not-last:data-[slot=card]:before:rounded-b-[calc(var(--radius-xl)-1px)] *:not-first:data-[slot=card]:rounded-t-xl *:not-first:data-[slot=card]:before:rounded-t-[calc(var(--radius-xl)-1px)] *:data-[slot=card]:[clip-path:inset(var(--clip-top)_1px_var(--clip-bottom)_1px_round_calc(var(--radius-2xl)-1px))] *:data-[slot=card]:shadow-none *:data-[slot=card]:before:hidden *:data-[slot=card]:bg-clip-padding", |
28 | | - className, |
29 | | - ), |
30 | | - "data-slot": "card-frame", |
31 | | - }; |
32 | | - |
33 | | - return useRender({ |
34 | | - defaultTagName: "div", |
35 | | - props: mergeProps<"div">(defaultProps, props), |
36 | | - render, |
37 | | - }); |
| 5 | +function Card({ className, ...props }: React.ComponentProps<"div">) { |
| 6 | + return ( |
| 7 | + <div |
| 8 | + data-slot="card" |
| 9 | + className={cn( |
| 10 | + "rounded-2xl border border-border/75 bg-card/82 text-card-foreground shadow-[0_24px_80px_-36px_hsl(220_70%_3%/0.95)] backdrop-blur-xl", |
| 11 | + className, |
| 12 | + )} |
| 13 | + {...props} |
| 14 | + /> |
| 15 | + ); |
38 | 16 | } |
39 | 17 |
|
40 | | -function CardFrameHeader({ className, render, ...props }: useRender.ComponentProps<"div">) { |
41 | | - const defaultProps = { |
42 | | - className: cn("relative flex flex-col px-6 py-4", className), |
43 | | - "data-slot": "card-frame-header", |
44 | | - }; |
45 | | - |
46 | | - return useRender({ |
47 | | - defaultTagName: "div", |
48 | | - props: mergeProps<"div">(defaultProps, props), |
49 | | - render, |
50 | | - }); |
| 18 | +function CardHeader({ className, ...props }: React.ComponentProps<"div">) { |
| 19 | + return ( |
| 20 | + <div |
| 21 | + data-slot="card-header" |
| 22 | + className={cn("flex flex-col gap-1.5 p-6", className)} |
| 23 | + {...props} |
| 24 | + /> |
| 25 | + ); |
51 | 26 | } |
52 | 27 |
|
53 | | -function CardFrameTitle({ className, render, ...props }: useRender.ComponentProps<"div">) { |
54 | | - const defaultProps = { |
55 | | - className: cn("font-semibold text-sm", className), |
56 | | - "data-slot": "card-frame-title", |
57 | | - }; |
58 | | - |
59 | | - return useRender({ |
60 | | - defaultTagName: "div", |
61 | | - props: mergeProps<"div">(defaultProps, props), |
62 | | - render, |
63 | | - }); |
| 28 | +function CardTitle({ className, ...props }: React.ComponentProps<"div">) { |
| 29 | + return ( |
| 30 | + <div |
| 31 | + data-slot="card-title" |
| 32 | + className={cn("leading-none font-semibold tracking-tight", className)} |
| 33 | + {...props} |
| 34 | + /> |
| 35 | + ); |
64 | 36 | } |
65 | 37 |
|
66 | | -function CardFrameDescription({ className, render, ...props }: useRender.ComponentProps<"div">) { |
67 | | - const defaultProps = { |
68 | | - className: cn("text-muted-foreground text-sm", className), |
69 | | - "data-slot": "card-frame-description", |
70 | | - }; |
71 | | - |
72 | | - return useRender({ |
73 | | - defaultTagName: "div", |
74 | | - props: mergeProps<"div">(defaultProps, props), |
75 | | - render, |
76 | | - }); |
| 38 | +function CardDescription({ className, ...props }: React.ComponentProps<"div">) { |
| 39 | + return ( |
| 40 | + <div |
| 41 | + data-slot="card-description" |
| 42 | + className={cn("text-sm text-muted-foreground", className)} |
| 43 | + {...props} |
| 44 | + /> |
| 45 | + ); |
77 | 46 | } |
78 | 47 |
|
79 | | -function CardFrameFooter({ className, render, ...props }: useRender.ComponentProps<"div">) { |
80 | | - const defaultProps = { |
81 | | - className: cn("px-6 py-4", className), |
82 | | - "data-slot": "card-frame-footer", |
83 | | - }; |
84 | | - |
85 | | - return useRender({ |
86 | | - defaultTagName: "div", |
87 | | - props: mergeProps<"div">(defaultProps, props), |
88 | | - render, |
89 | | - }); |
| 48 | +function CardAction({ className, ...props }: React.ComponentProps<"div">) { |
| 49 | + return ( |
| 50 | + <div |
| 51 | + data-slot="card-action" |
| 52 | + className={cn("col-start-2 row-span-2 row-start-1 self-start justify-self-end", className)} |
| 53 | + {...props} |
| 54 | + /> |
| 55 | + ); |
90 | 56 | } |
91 | 57 |
|
92 | | -function CardHeader({ className, render, ...props }: useRender.ComponentProps<"div">) { |
93 | | - const defaultProps = { |
94 | | - className: cn( |
95 | | - "grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 p-6 in-[[data-slot=card]:has(>[data-slot=card-panel])]:pb-4 has-data-[slot=card-action]:grid-cols-[1fr_auto]", |
96 | | - className, |
97 | | - ), |
98 | | - "data-slot": "card-header", |
99 | | - }; |
100 | | - |
101 | | - return useRender({ |
102 | | - defaultTagName: "div", |
103 | | - props: mergeProps<"div">(defaultProps, props), |
104 | | - render, |
105 | | - }); |
| 58 | +function CardContent({ className, ...props }: React.ComponentProps<"div">) { |
| 59 | + return <div data-slot="card-content" className={cn("px-6 pb-6", className)} {...props} />; |
106 | 60 | } |
107 | 61 |
|
108 | | -function CardTitle({ className, render, ...props }: useRender.ComponentProps<"div">) { |
109 | | - const defaultProps = { |
110 | | - className: cn("font-semibold text-lg leading-none", className), |
111 | | - "data-slot": "card-title", |
112 | | - }; |
113 | | - |
114 | | - return useRender({ |
115 | | - defaultTagName: "div", |
116 | | - props: mergeProps<"div">(defaultProps, props), |
117 | | - render, |
118 | | - }); |
119 | | -} |
120 | | - |
121 | | -function CardDescription({ className, render, ...props }: useRender.ComponentProps<"div">) { |
122 | | - const defaultProps = { |
123 | | - className: cn("text-muted-foreground text-sm", className), |
124 | | - "data-slot": "card-description", |
125 | | - }; |
126 | | - |
127 | | - return useRender({ |
128 | | - defaultTagName: "div", |
129 | | - props: mergeProps<"div">(defaultProps, props), |
130 | | - render, |
131 | | - }); |
132 | | -} |
133 | | - |
134 | | -function CardAction({ className, render, ...props }: useRender.ComponentProps<"div">) { |
135 | | - const defaultProps = { |
136 | | - className: cn( |
137 | | - "col-start-2 row-span-2 row-start-1 self-start justify-self-end inline-flex", |
138 | | - className, |
139 | | - ), |
140 | | - "data-slot": "card-action", |
141 | | - }; |
142 | | - |
143 | | - return useRender({ |
144 | | - defaultTagName: "div", |
145 | | - props: mergeProps<"div">(defaultProps, props), |
146 | | - render, |
147 | | - }); |
148 | | -} |
149 | | - |
150 | | -function CardPanel({ className, render, ...props }: useRender.ComponentProps<"div">) { |
151 | | - const defaultProps = { |
152 | | - className: cn( |
153 | | - "flex-1 p-6 in-[[data-slot=card]:has(>[data-slot=card-header]:not(.border-b))]:pt-0 in-[[data-slot=card]:has(>[data-slot=card-footer]:not(.border-t))]:pb-0", |
154 | | - className, |
155 | | - ), |
156 | | - "data-slot": "card-panel", |
157 | | - }; |
158 | | - |
159 | | - return useRender({ |
160 | | - defaultTagName: "div", |
161 | | - props: mergeProps<"div">(defaultProps, props), |
162 | | - render, |
163 | | - }); |
164 | | -} |
165 | | - |
166 | | -function CardFooter({ className, render, ...props }: useRender.ComponentProps<"div">) { |
167 | | - const defaultProps = { |
168 | | - className: cn( |
169 | | - "flex items-center p-6 in-[[data-slot=card]:has(>[data-slot=card-panel])]:pt-4", |
170 | | - className, |
171 | | - ), |
172 | | - "data-slot": "card-footer", |
173 | | - }; |
174 | | - |
175 | | - return useRender({ |
176 | | - defaultTagName: "div", |
177 | | - props: mergeProps<"div">(defaultProps, props), |
178 | | - render, |
179 | | - }); |
| 62 | +function CardFooter({ className, ...props }: React.ComponentProps<"div">) { |
| 63 | + return ( |
| 64 | + <div |
| 65 | + data-slot="card-footer" |
| 66 | + className={cn("flex items-center px-6 pb-6", className)} |
| 67 | + {...props} |
| 68 | + /> |
| 69 | + ); |
180 | 70 | } |
181 | 71 |
|
182 | | -export { |
183 | | - Card, |
184 | | - CardFrame, |
185 | | - CardFrameHeader, |
186 | | - CardFrameTitle, |
187 | | - CardFrameDescription, |
188 | | - CardFrameFooter, |
189 | | - CardAction, |
190 | | - CardDescription, |
191 | | - CardFooter, |
192 | | - CardHeader, |
193 | | - CardPanel, |
194 | | - CardPanel as CardContent, |
195 | | - CardTitle, |
196 | | -}; |
| 72 | +export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent }; |
0 commit comments