create-bluecopa-react-app 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,150 @@
1
+ import React from 'react';
2
+ import { useMetric, useDatasetSample } from '@bluecopa/react';
3
+ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
4
+ import { Button } from '@/components/ui/button';
5
+ import { RefreshCw, TrendingUp, Package, CreditCard, Users } from 'lucide-react';
6
+
7
+ interface MetricCardProps {
8
+ title: string;
9
+ value: string | number;
10
+ description?: string;
11
+ icon?: React.ReactNode;
12
+ trend?: {
13
+ value: number;
14
+ isPositive: boolean;
15
+ };
16
+ }
17
+
18
+ const MetricCard: React.FC<MetricCardProps> = ({ title, value, description, icon, trend }) => {
19
+ return (
20
+ <Card>
21
+ <CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
22
+ <CardTitle className="text-sm font-medium">{title}</CardTitle>
23
+ {icon}
24
+ </CardHeader>
25
+ <CardContent>
26
+ <div className="text-2xl font-bold">{typeof value === 'number' ? value.toLocaleString() : value}</div>
27
+ {description && (
28
+ <p className="text-xs text-muted-foreground">{description}</p>
29
+ )}
30
+ {trend && (
31
+ <div className={`flex items-center text-xs ${trend.isPositive ? 'text-green-600' : 'text-red-600'}`}>
32
+ <TrendingUp className="mr-1 h-3 w-3" />
33
+ {trend.isPositive ? '+' : ''}{trend.value}% from last month
34
+ </div>
35
+ )}
36
+ </CardContent>
37
+ </Card>
38
+ );
39
+ };
40
+
41
+ export const MetricsOverview: React.FC = () => {
42
+ const {
43
+ data: metricData,
44
+ isLoading: metricLoading,
45
+ error: metricError,
46
+ refetch: refetchMetric
47
+ } = useMetric("0UbwCn75pym1N47D89uS");
48
+
49
+ const {
50
+ data: datasetData,
51
+ isLoading: datasetLoading,
52
+ error: datasetError,
53
+ } = useDatasetSample("0UvoE3CHwqYqzrbGdgs1_large_transaction_dataset_csv");
54
+
55
+ // Calculate metrics from transaction data
56
+ const calculateMetrics = () => {
57
+ if (!datasetData?.data?.data) return null;
58
+
59
+ const transactions = datasetData.data.data;
60
+ const totalTransactions = transactions.length;
61
+ const totalRevenue = transactions.reduce((sum, t) => sum + t.total_amount, 0);
62
+ const avgOrderValue = totalRevenue / totalTransactions;
63
+ const uniqueProducts = new Set(transactions.map(t => t.product_id)).size;
64
+
65
+ return {
66
+ totalTransactions,
67
+ totalRevenue,
68
+ avgOrderValue,
69
+ uniqueProducts
70
+ };
71
+ };
72
+
73
+ const metrics = calculateMetrics();
74
+
75
+ if (metricLoading || datasetLoading) {
76
+ return (
77
+ <div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
78
+ {[1, 2, 3, 4].map((i) => (
79
+ <Card key={i}>
80
+ <CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
81
+ <div className="h-4 w-20 bg-muted animate-pulse rounded"></div>
82
+ <div className="h-4 w-4 bg-muted animate-pulse rounded"></div>
83
+ </CardHeader>
84
+ <CardContent>
85
+ <div className="h-8 w-24 bg-muted animate-pulse rounded mb-2"></div>
86
+ <div className="h-3 w-32 bg-muted animate-pulse rounded"></div>
87
+ </CardContent>
88
+ </Card>
89
+ ))}
90
+ </div>
91
+ );
92
+ }
93
+
94
+ if (metricError || datasetError) {
95
+ return (
96
+ <div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
97
+ <Card className="md:col-span-2 lg:col-span-4">
98
+ <CardHeader>
99
+ <CardTitle className="text-red-600">Error Loading Metrics</CardTitle>
100
+ </CardHeader>
101
+ <CardContent>
102
+ <p className="text-muted-foreground mb-4">
103
+ Failed to load dashboard metrics. Please try refreshing.
104
+ </p>
105
+ <Button onClick={() => refetchMetric()} className="flex items-center gap-2">
106
+ <RefreshCw className="h-4 w-4" />
107
+ Retry
108
+ </Button>
109
+ </CardContent>
110
+ </Card>
111
+ </div>
112
+ );
113
+ }
114
+
115
+ return (
116
+ <div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
117
+ <MetricCard
118
+ title="Total Revenue"
119
+ value={`₹${metricData?.data[0]?.TotalAmount?.toLocaleString() || 0}`}
120
+ description="Total amount from all transactions"
121
+ icon={<TrendingUp className="h-4 w-4 text-muted-foreground" />}
122
+ trend={{ value: 12.5, isPositive: true }}
123
+ />
124
+
125
+ <MetricCard
126
+ title="Total Transactions"
127
+ value={metrics?.totalTransactions || 0}
128
+ description="Number of completed transactions"
129
+ icon={<CreditCard className="h-4 w-4 text-muted-foreground" />}
130
+ trend={{ value: 8.2, isPositive: true }}
131
+ />
132
+
133
+ <MetricCard
134
+ title="Average Order Value"
135
+ value={`₹${metrics?.avgOrderValue?.toFixed(2) || 0}`}
136
+ description="Average transaction amount"
137
+ icon={<Package className="h-4 w-4 text-muted-foreground" />}
138
+ trend={{ value: -2.1, isPositive: false }}
139
+ />
140
+
141
+ <MetricCard
142
+ title="Unique Products"
143
+ value={metrics?.uniqueProducts || 0}
144
+ description="Number of different products sold"
145
+ icon={<Users className="h-4 w-4 text-muted-foreground" />}
146
+ trend={{ value: 5.7, isPositive: true }}
147
+ />
148
+ </div>
149
+ );
150
+ };
@@ -0,0 +1,215 @@
1
+ import React from 'react';
2
+ import { useDatasetSample } from '@bluecopa/react';
3
+ import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, PieChart, Pie, Cell, LineChart, Line } from 'recharts';
4
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
5
+ import { CategorySalesData, PaymentMethodData, StateAnalytics } from '@/types';
6
+
7
+ const COLORS = ['#0088FE', '#00C49F', '#FFBB28', '#FF8042', '#8884D8', '#82CA9D'];
8
+
9
+ export const TransactionCharts: React.FC = () => {
10
+ const {
11
+ data: datasetData,
12
+ isLoading,
13
+ error,
14
+ } = useDatasetSample("0UvoE3CHwqYqzrbGdgs1_large_transaction_dataset_csv");
15
+
16
+ // Process data for charts
17
+ const processChartData = () => {
18
+ if (!datasetData?.data?.data) return { categoryData: [], paymentData: [], stateData: [] };
19
+
20
+ const transactions = datasetData.data.data;
21
+
22
+ // Category sales data
23
+ const categoryMap = new Map<string, CategorySalesData>();
24
+ transactions.forEach(transaction => {
25
+ const category = transaction.category;
26
+ if (categoryMap.has(category)) {
27
+ const existing = categoryMap.get(category)!;
28
+ existing.totalSales += transaction.total_amount;
29
+ existing.quantity += transaction.quantity;
30
+ } else {
31
+ categoryMap.set(category, {
32
+ category,
33
+ totalSales: transaction.total_amount,
34
+ quantity: transaction.quantity
35
+ });
36
+ }
37
+ });
38
+
39
+ // Payment method data
40
+ const paymentMap = new Map<string, PaymentMethodData>();
41
+ transactions.forEach(transaction => {
42
+ const method = transaction.payment_method;
43
+ if (paymentMap.has(method)) {
44
+ const existing = paymentMap.get(method)!;
45
+ existing.count += 1;
46
+ existing.totalAmount += transaction.total_amount;
47
+ } else {
48
+ paymentMap.set(method, {
49
+ paymentMethod: method,
50
+ count: 1,
51
+ totalAmount: transaction.total_amount
52
+ });
53
+ }
54
+ });
55
+
56
+ // State analytics data
57
+ const stateMap = new Map<string, StateAnalytics>();
58
+ transactions.forEach(transaction => {
59
+ const state = transaction.state;
60
+ if (stateMap.has(state)) {
61
+ const existing = stateMap.get(state)!;
62
+ existing.totalTransactions += 1;
63
+ existing.totalAmount += transaction.total_amount;
64
+ existing.averageOrderValue = existing.totalAmount / existing.totalTransactions;
65
+ } else {
66
+ stateMap.set(state, {
67
+ state,
68
+ totalTransactions: 1,
69
+ totalAmount: transaction.total_amount,
70
+ averageOrderValue: transaction.total_amount
71
+ });
72
+ }
73
+ });
74
+
75
+ return {
76
+ categoryData: Array.from(categoryMap.values()).sort((a, b) => b.totalSales - a.totalSales),
77
+ paymentData: Array.from(paymentMap.values()).sort((a, b) => b.count - a.count),
78
+ stateData: Array.from(stateMap.values()).sort((a, b) => b.totalAmount - a.totalAmount)
79
+ };
80
+ };
81
+
82
+ if (isLoading) {
83
+ return (
84
+ <div className="grid gap-4 md:grid-cols-2">
85
+ {[1, 2, 3, 4].map((i) => (
86
+ <Card key={i}>
87
+ <CardHeader>
88
+ <div className="h-6 w-48 bg-muted animate-pulse rounded"></div>
89
+ </CardHeader>
90
+ <CardContent>
91
+ <div className="h-64 bg-muted animate-pulse rounded"></div>
92
+ </CardContent>
93
+ </Card>
94
+ ))}
95
+ </div>
96
+ );
97
+ }
98
+
99
+ if (error) {
100
+ return (
101
+ <Card>
102
+ <CardHeader>
103
+ <CardTitle className="text-red-600">Error Loading Charts</CardTitle>
104
+ </CardHeader>
105
+ <CardContent>
106
+ <p className="text-muted-foreground">Failed to load chart data. Please try refreshing the page.</p>
107
+ </CardContent>
108
+ </Card>
109
+ );
110
+ }
111
+
112
+ const { categoryData, paymentData, stateData } = processChartData();
113
+
114
+ return (
115
+ <div className="grid gap-4 md:grid-cols-2">
116
+ {/* Category Sales Chart */}
117
+ <Card>
118
+ <CardHeader>
119
+ <CardTitle>Sales by Category</CardTitle>
120
+ <CardDescription>Revenue distribution across product categories</CardDescription>
121
+ </CardHeader>
122
+ <CardContent>
123
+ <ResponsiveContainer width="100%" height={300}>
124
+ <BarChart data={categoryData}>
125
+ <CartesianGrid strokeDasharray="3 3" />
126
+ <XAxis dataKey="category" />
127
+ <YAxis />
128
+ <Tooltip
129
+ formatter={(value: number, name: string) => [
130
+ `₹${value.toLocaleString()}`,
131
+ name === 'totalSales' ? 'Total Sales' : name
132
+ ]}
133
+ />
134
+ <Bar dataKey="totalSales" fill="#8884d8" />
135
+ </BarChart>
136
+ </ResponsiveContainer>
137
+ </CardContent>
138
+ </Card>
139
+
140
+ {/* Payment Method Distribution */}
141
+ <Card>
142
+ <CardHeader>
143
+ <CardTitle>Payment Method Distribution</CardTitle>
144
+ <CardDescription>Transaction count by payment method</CardDescription>
145
+ </CardHeader>
146
+ <CardContent>
147
+ <ResponsiveContainer width="100%" height={300}>
148
+ <PieChart>
149
+ <Pie
150
+ data={paymentData}
151
+ cx="50%"
152
+ cy="50%"
153
+ labelLine={false}
154
+ label={({ paymentMethod, percent }: any) => `${paymentMethod} ${(percent * 100).toFixed(0)}%`}
155
+ outerRadius={80}
156
+ fill="#8884d8"
157
+ dataKey="count"
158
+ >
159
+ {paymentData.map((_, index) => (
160
+ <Cell key={`cell-${index}`} fill={COLORS[index % COLORS.length]} />
161
+ ))}
162
+ </Pie>
163
+ <Tooltip formatter={(value: number) => [value, 'Transactions']} />
164
+ </PieChart>
165
+ </ResponsiveContainer>
166
+ </CardContent>
167
+ </Card>
168
+
169
+ {/* State Analytics */}
170
+ <Card>
171
+ <CardHeader>
172
+ <CardTitle>Revenue by State</CardTitle>
173
+ <CardDescription>Total revenue and transaction count by state</CardDescription>
174
+ </CardHeader>
175
+ <CardContent>
176
+ <ResponsiveContainer width="100%" height={300}>
177
+ <BarChart data={stateData}>
178
+ <CartesianGrid strokeDasharray="3 3" />
179
+ <XAxis dataKey="state" />
180
+ <YAxis />
181
+ <Tooltip
182
+ formatter={(value: number, name: string) => [
183
+ name === 'totalAmount' ? `₹${value.toLocaleString()}` : value,
184
+ name === 'totalAmount' ? 'Total Revenue' : 'Transactions'
185
+ ]}
186
+ />
187
+ <Bar dataKey="totalAmount" fill="#82ca9d" />
188
+ </BarChart>
189
+ </ResponsiveContainer>
190
+ </CardContent>
191
+ </Card>
192
+
193
+ {/* Average Order Value Trend */}
194
+ <Card>
195
+ <CardHeader>
196
+ <CardTitle>Average Order Value by State</CardTitle>
197
+ <CardDescription>AOV comparison across different states</CardDescription>
198
+ </CardHeader>
199
+ <CardContent>
200
+ <ResponsiveContainer width="100%" height={300}>
201
+ <LineChart data={stateData}>
202
+ <CartesianGrid strokeDasharray="3 3" />
203
+ <XAxis dataKey="state" />
204
+ <YAxis />
205
+ <Tooltip
206
+ formatter={(value: number) => [`₹${value.toFixed(2)}`, 'Average Order Value']}
207
+ />
208
+ <Line type="monotone" dataKey="averageOrderValue" stroke="#8884d8" strokeWidth={2} />
209
+ </LineChart>
210
+ </ResponsiveContainer>
211
+ </CardContent>
212
+ </Card>
213
+ </div>
214
+ );
215
+ };
@@ -0,0 +1,172 @@
1
+ import React from 'react';
2
+ import { useDatasetSample } from '@bluecopa/react';
3
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
4
+ import { Button } from '@/components/ui/button';
5
+ import { RefreshCw, Search, Filter } from 'lucide-react';
6
+
7
+ export const TransactionTable: React.FC = () => {
8
+ const {
9
+ data: datasetData,
10
+ isLoading,
11
+ error,
12
+ refetch
13
+ } = useDatasetSample("0UvoE3CHwqYqzrbGdgs1_large_transaction_dataset_csv");
14
+
15
+ const formatCurrency = (amount: number) => {
16
+ return new Intl.NumberFormat('en-IN', {
17
+ style: 'currency',
18
+ currency: 'INR',
19
+ }).format(amount);
20
+ };
21
+
22
+ const formatDate = (dateString: string) => {
23
+ return new Date(dateString).toLocaleDateString('en-IN');
24
+ };
25
+
26
+ if (isLoading) {
27
+ return (
28
+ <Card>
29
+ <CardHeader>
30
+ <div className="flex items-center justify-between">
31
+ <div>
32
+ <div className="h-6 w-48 bg-muted animate-pulse rounded mb-2"></div>
33
+ <div className="h-4 w-64 bg-muted animate-pulse rounded"></div>
34
+ </div>
35
+ <div className="h-10 w-24 bg-muted animate-pulse rounded"></div>
36
+ </div>
37
+ </CardHeader>
38
+ <CardContent>
39
+ <div className="space-y-4">
40
+ {[1, 2, 3, 4, 5].map((i) => (
41
+ <div key={i} className="flex items-center space-x-4">
42
+ <div className="h-4 w-20 bg-muted animate-pulse rounded"></div>
43
+ <div className="h-4 w-32 bg-muted animate-pulse rounded"></div>
44
+ <div className="h-4 w-24 bg-muted animate-pulse rounded"></div>
45
+ <div className="h-4 w-28 bg-muted animate-pulse rounded"></div>
46
+ <div className="h-4 w-20 bg-muted animate-pulse rounded"></div>
47
+ </div>
48
+ ))}
49
+ </div>
50
+ </CardContent>
51
+ </Card>
52
+ );
53
+ }
54
+
55
+ if (error) {
56
+ return (
57
+ <Card>
58
+ <CardHeader>
59
+ <CardTitle className="text-red-600">Error Loading Transaction Data</CardTitle>
60
+ </CardHeader>
61
+ <CardContent>
62
+ <p className="text-muted-foreground mb-4">
63
+ Failed to load transaction data. Please try refreshing.
64
+ </p>
65
+ <Button onClick={() => refetch()} className="flex items-center gap-2">
66
+ <RefreshCw className="h-4 w-4" />
67
+ Retry
68
+ </Button>
69
+ </CardContent>
70
+ </Card>
71
+ );
72
+ }
73
+
74
+ const transactions = datasetData?.data?.data || [];
75
+
76
+ return (
77
+ <Card>
78
+ <CardHeader>
79
+ <div className="flex items-center justify-between">
80
+ <div>
81
+ <CardTitle>Transaction Data</CardTitle>
82
+ <CardDescription>
83
+ Recent transactions from the BlueCopa dataset ({transactions.length} records)
84
+ </CardDescription>
85
+ </div>
86
+ <div className="flex gap-2">
87
+ <Button variant="outline" size="sm" className="flex items-center gap-2">
88
+ <Search className="h-4 w-4" />
89
+ Search
90
+ </Button>
91
+ <Button variant="outline" size="sm" className="flex items-center gap-2">
92
+ <Filter className="h-4 w-4" />
93
+ Filter
94
+ </Button>
95
+ <Button onClick={() => refetch()} size="sm" className="flex items-center gap-2">
96
+ <RefreshCw className="h-4 w-4" />
97
+ Refresh
98
+ </Button>
99
+ </div>
100
+ </div>
101
+ </CardHeader>
102
+ <CardContent>
103
+ <div className="overflow-x-auto">
104
+ <table className="w-full border-collapse">
105
+ <thead>
106
+ <tr className="border-b">
107
+ <th className="text-left p-2 font-medium">Transaction ID</th>
108
+ <th className="text-left p-2 font-medium">Date</th>
109
+ <th className="text-left p-2 font-medium">City</th>
110
+ <th className="text-left p-2 font-medium">Category</th>
111
+ <th className="text-left p-2 font-medium">Product</th>
112
+ <th className="text-left p-2 font-medium">Quantity</th>
113
+ <th className="text-left p-2 font-medium">Unit Price</th>
114
+ <th className="text-left p-2 font-medium">Total Amount</th>
115
+ <th className="text-left p-2 font-medium">Payment Method</th>
116
+ <th className="text-left p-2 font-medium">Channel</th>
117
+ <th className="text-left p-2 font-medium">Status</th>
118
+ </tr>
119
+ </thead>
120
+ <tbody>
121
+ {transactions.slice(0, 10).map((transaction, index) => (
122
+ <tr key={transaction.transaction_id} className={index % 2 === 0 ? 'bg-muted/50' : ''}>
123
+ <td className="p-2 font-mono text-sm">{transaction.transaction_id}</td>
124
+ <td className="p-2">{formatDate(transaction.transaction_day)}</td>
125
+ <td className="p-2">{transaction.city}</td>
126
+ <td className="p-2">
127
+ <span className="inline-flex items-center px-2 py-1 rounded-full text-xs bg-blue-100 text-blue-800">
128
+ {transaction.category}
129
+ </span>
130
+ </td>
131
+ <td className="p-2 font-mono text-sm">{transaction.product_id}</td>
132
+ <td className="p-2 text-center">{transaction.quantity}</td>
133
+ <td className="p-2">{formatCurrency(transaction.unit_price)}</td>
134
+ <td className="p-2 font-semibold">{formatCurrency(transaction.total_amount)}</td>
135
+ <td className="p-2">
136
+ <span className={`inline-flex items-center px-2 py-1 rounded-full text-xs ${
137
+ transaction.payment_method === 'Credit Card' ? 'bg-green-100 text-green-800' :
138
+ transaction.payment_method === 'Debit Card' ? 'bg-yellow-100 text-yellow-800' :
139
+ transaction.payment_method === 'UPI' ? 'bg-purple-100 text-purple-800' :
140
+ 'bg-gray-100 text-gray-800'
141
+ }`}>
142
+ {transaction.payment_method}
143
+ </span>
144
+ </td>
145
+ <td className="p-2">{transaction.channel}</td>
146
+ <td className="p-2">
147
+ <span className={`inline-flex items-center px-2 py-1 rounded-full text-xs ${
148
+ transaction.is_online ? 'bg-green-100 text-green-800' : 'bg-orange-100 text-orange-800'
149
+ }`}>
150
+ {transaction.is_online ? 'Online' : 'Offline'}
151
+ </span>
152
+ </td>
153
+ </tr>
154
+ ))}
155
+ </tbody>
156
+ </table>
157
+
158
+ {transactions.length > 10 && (
159
+ <div className="mt-4 text-center">
160
+ <p className="text-muted-foreground text-sm">
161
+ Showing 10 of {transactions.length} transactions
162
+ </p>
163
+ <Button variant="outline" className="mt-2">
164
+ View All Transactions
165
+ </Button>
166
+ </div>
167
+ )}
168
+ </div>
169
+ </CardContent>
170
+ </Card>
171
+ );
172
+ };
@@ -0,0 +1,64 @@
1
+ import * as React from "react"
2
+ import { cva, type VariantProps } from "class-variance-authority"
3
+
4
+ import { cn } from "@/lib/utils"
5
+
6
+ const buttonVariants = cva(
7
+ "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
12
+ destructive:
13
+ "bg-destructive text-destructive-foreground hover:bg-destructive/90",
14
+ outline:
15
+ "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
16
+ secondary:
17
+ "bg-secondary text-secondary-foreground hover:bg-secondary/80",
18
+ ghost: "hover:bg-accent hover:text-accent-foreground",
19
+ link: "text-primary underline-offset-4 hover:underline",
20
+ },
21
+ size: {
22
+ default: "h-10 px-4 py-2",
23
+ sm: "h-9 rounded-md px-3",
24
+ lg: "h-11 rounded-md px-8",
25
+ icon: "h-10 w-10",
26
+ },
27
+ },
28
+ defaultVariants: {
29
+ variant: "default",
30
+ size: "default",
31
+ },
32
+ }
33
+ )
34
+
35
+ export interface ButtonProps
36
+ extends React.ButtonHTMLAttributes<HTMLButtonElement>,
37
+ VariantProps<typeof buttonVariants> {
38
+ asChild?: boolean
39
+ }
40
+
41
+ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
42
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
43
+ // Removed unused variable 'Comp'
44
+ if (asChild) {
45
+ // Only pass className and children to slot, not button-specific props
46
+ const { children } = props;
47
+ return (
48
+ <slot className={cn(buttonVariants({ variant, size, className }))}>
49
+ {children}
50
+ </slot>
51
+ );
52
+ }
53
+ return (
54
+ <button
55
+ className={cn(buttonVariants({ variant, size, className }))}
56
+ ref={ref}
57
+ {...props}
58
+ />
59
+ )
60
+ }
61
+ )
62
+ Button.displayName = "Button"
63
+
64
+ export { Button, buttonVariants }
@@ -0,0 +1,79 @@
1
+ import * as React from "react"
2
+
3
+ import { cn } from "@/lib/utils"
4
+
5
+ const Card = React.forwardRef<
6
+ HTMLDivElement,
7
+ React.HTMLAttributes<HTMLDivElement>
8
+ >(({ className, ...props }, ref) => (
9
+ <div
10
+ ref={ref}
11
+ className={cn(
12
+ "rounded-lg border bg-card text-card-foreground shadow-sm",
13
+ className
14
+ )}
15
+ {...props}
16
+ />
17
+ ))
18
+ Card.displayName = "Card"
19
+
20
+ const CardHeader = React.forwardRef<
21
+ HTMLDivElement,
22
+ React.HTMLAttributes<HTMLDivElement>
23
+ >(({ className, ...props }, ref) => (
24
+ <div
25
+ ref={ref}
26
+ className={cn("flex flex-col space-y-1.5 p-6", className)}
27
+ {...props}
28
+ />
29
+ ))
30
+ CardHeader.displayName = "CardHeader"
31
+
32
+ const CardTitle = React.forwardRef<
33
+ HTMLParagraphElement,
34
+ React.HTMLAttributes<HTMLHeadingElement>
35
+ >(({ className, ...props }, ref) => (
36
+ <h3
37
+ ref={ref}
38
+ className={cn(
39
+ "text-2xl font-semibold leading-none tracking-tight",
40
+ className
41
+ )}
42
+ {...props}
43
+ />
44
+ ))
45
+ CardTitle.displayName = "CardTitle"
46
+
47
+ const CardDescription = React.forwardRef<
48
+ HTMLParagraphElement,
49
+ React.HTMLAttributes<HTMLParagraphElement>
50
+ >(({ className, ...props }, ref) => (
51
+ <p
52
+ ref={ref}
53
+ className={cn("text-sm text-muted-foreground", className)}
54
+ {...props}
55
+ />
56
+ ))
57
+ CardDescription.displayName = "CardDescription"
58
+
59
+ const CardContent = React.forwardRef<
60
+ HTMLDivElement,
61
+ React.HTMLAttributes<HTMLDivElement>
62
+ >(({ className, ...props }, ref) => (
63
+ <div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
64
+ ))
65
+ CardContent.displayName = "CardContent"
66
+
67
+ const CardFooter = React.forwardRef<
68
+ HTMLDivElement,
69
+ React.HTMLAttributes<HTMLDivElement>
70
+ >(({ className, ...props }, ref) => (
71
+ <div
72
+ ref={ref}
73
+ className={cn("flex items-center p-6 pt-0", className)}
74
+ {...props}
75
+ />
76
+ ))
77
+ CardFooter.displayName = "CardFooter"
78
+
79
+ export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }