card
This commit is contained in:
+84
-35
@@ -1,43 +1,92 @@
|
|||||||
import * as React from "react";
|
import * as React from "react"
|
||||||
|
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
|
function Card({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
<div ref={ref} className={cn("rounded-lg border bg-card text-card-foreground shadow-sm", className)} {...props} />
|
return (
|
||||||
));
|
<div
|
||||||
Card.displayName = "Card";
|
data-slot="card"
|
||||||
|
className={cn(
|
||||||
|
"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
({ className, ...props }, ref) => (
|
return (
|
||||||
<div ref={ref} className={cn("flex flex-col space-y-1.5 p-6", className)} {...props} />
|
<div
|
||||||
),
|
data-slot="card-header"
|
||||||
);
|
className={cn(
|
||||||
CardHeader.displayName = "CardHeader";
|
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const CardTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(
|
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
({ className, ...props }, ref) => (
|
return (
|
||||||
<h3 ref={ref} className={cn("text-2xl font-semibold leading-none tracking-tight", className)} {...props} />
|
<div
|
||||||
),
|
data-slot="card-title"
|
||||||
);
|
className={cn("leading-none font-semibold", className)}
|
||||||
CardTitle.displayName = "CardTitle";
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const CardDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
|
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
({ className, ...props }, ref) => (
|
return (
|
||||||
<p ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
<div
|
||||||
),
|
data-slot="card-description"
|
||||||
);
|
className={cn("text-muted-foreground text-sm", className)}
|
||||||
CardDescription.displayName = "CardDescription";
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
({ className, ...props }, ref) => <div ref={ref} className={cn("p-6 pt-0", className)} {...props} />,
|
return (
|
||||||
);
|
<div
|
||||||
CardContent.displayName = "CardContent";
|
data-slot="card-action"
|
||||||
|
className={cn(
|
||||||
|
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
({ className, ...props }, ref) => (
|
return (
|
||||||
<div ref={ref} className={cn("flex items-center p-6 pt-0", className)} {...props} />
|
<div
|
||||||
),
|
data-slot="card-content"
|
||||||
);
|
className={cn("px-6", className)}
|
||||||
CardFooter.displayName = "CardFooter";
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
|
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="card-footer"
|
||||||
|
className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
Card,
|
||||||
|
CardHeader,
|
||||||
|
CardFooter,
|
||||||
|
CardTitle,
|
||||||
|
CardAction,
|
||||||
|
CardDescription,
|
||||||
|
CardContent,
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user