'use client'; import * as React from 'react'; import { cn } from '@/lib/utils'; import { cva, type VariantProps } from 'class-variance-authority'; // Define CardContext type CardContextType = { variant: 'default' | 'accent'; }; const CardContext = React.createContext({ variant: 'default', // Default value }); // Hook to use CardContext const useCardContext = () => { const context = React.useContext(CardContext); if (!context) { throw new Error('useCardContext must be used within a Card component'); } return context; }; // Variants const cardVariants = cva('flex flex-col items-stretch text-card-foreground rounded-xl', { variants: { variant: { default: 'bg-card border border-border shadow-xs black/5', accent: 'bg-muted shadow-xs p-1', }, }, defaultVariants: { variant: 'default', }, }); const cardHeaderVariants = cva('flex items-center justify-between flex-wrap px-5 min-h-14 gap-2.5', { variants: { variant: { default: 'border-b border-border', accent: '', }, }, defaultVariants: { variant: 'default', }, }); const cardContentVariants = cva('grow p-5', { variants: { variant: { default: '', accent: 'bg-card rounded-t-xl [&:last-child]:rounded-b-xl', }, }, defaultVariants: { variant: 'default', }, }); const cardTableVariants = cva('grid grow', { variants: { variant: { default: '', accent: 'bg-card rounded-xl', }, }, defaultVariants: { variant: 'default', }, }); const cardFooterVariants = cva('flex items-center px-5 min-h-14', { variants: { variant: { default: 'border-t border-border', accent: 'bg-card rounded-b-xl mt-[2px]', }, }, defaultVariants: { variant: 'default', }, }); // Card Component function Card({ className, variant = 'default', ...props }: React.HTMLAttributes & VariantProps) { return (
); } // CardHeader Component function CardHeader({ className, ...props }: React.HTMLAttributes) { const { variant } = useCardContext(); return
; } // CardContent Component function CardContent({ className, ...props }: React.HTMLAttributes) { const { variant } = useCardContext(); return
; } // CardTable Component function CardTable({ className, ...props }: React.HTMLAttributes) { const { variant } = useCardContext(); return
; } // CardFooter Component function CardFooter({ className, ...props }: React.HTMLAttributes) { const { variant } = useCardContext(); return
; } // Other Components function CardHeading({ className, ...props }: React.HTMLAttributes) { return
; } function CardToolbar({ className, ...props }: React.HTMLAttributes) { return
; } function CardTitle({ className, ...props }: React.HTMLAttributes) { return (

); } function CardDescription({ className, ...props }: React.HTMLAttributes) { return
; } // Exports export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardHeading, CardTable, CardTitle, CardToolbar };