forked from Movalabs-crew/mova-store
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSkeleton.tsx
More file actions
183 lines (170 loc) · 4.39 KB
/
Copy pathSkeleton.tsx
File metadata and controls
183 lines (170 loc) · 4.39 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
172
173
174
175
176
177
178
179
180
181
182
183
"use client";
interface SkeletonProps {
className?: string;
variant?: "text" | "circular" | "rectangular";
width?: string | number;
height?: string | number;
animation?: "pulse" | "wave" | "none";
}
/**
* Skeleton Component
*
* A placeholder component for loading states.
*
* Usage:
* ```tsx
* <Skeleton variant="text" width="80%" />
* <Skeleton variant="circular" width={40} height={40} />
* <Skeleton variant="rectangular" width="100%" height={200} />
* ```
*/
export default function Skeleton({
className = "",
variant = "rectangular",
width,
height,
animation = "pulse",
}: SkeletonProps) {
const baseClasses = "bg-gray-200";
const variantClasses = {
text: "rounded h-4",
circular: "rounded-full",
rectangular: "rounded",
};
const animationClasses = {
pulse: "animate-pulse",
wave: "skeleton-wave",
none: "",
};
const style: React.CSSProperties = {
width: typeof width === "number" ? `${width}px` : width,
height: typeof height === "number" ? `${height}px` : height,
};
return (
<div
className={`${baseClasses} ${variantClasses[variant]} ${animationClasses[animation]} ${className}`}
style={style}
aria-hidden="true"
role="presentation"
/>
);
}
/**
* Product Card Skeleton
*/
export function ProductCardSkeleton() {
return (
<div className="bg-white rounded-lg shadow-md p-4 space-y-4">
<Skeleton variant="rectangular" height={200} className="w-full" />
<Skeleton variant="text" width="70%" />
<Skeleton variant="text" width="40%" />
<div className="flex justify-between items-center">
<Skeleton variant="text" width="30%" />
<Skeleton variant="rectangular" width={80} height={32} />
</div>
</div>
);
}
/**
* Product Grid Skeleton
*/
export function ProductGridSkeleton({ count = 8 }: { count?: number }) {
return (
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6">
{Array.from({ length: count }).map((_, index) => (
<ProductCardSkeleton key={index} />
))}
</div>
);
}
/**
* Table Row Skeleton
*/
export function TableRowSkeleton({ columns = 4 }: { columns?: number }) {
return (
<tr className="border-b">
{Array.from({ length: columns }).map((_, index) => (
<td key={index} className="py-4 px-6">
<Skeleton variant="text" />
</td>
))}
</tr>
);
}
/**
* Table Skeleton
*/
export function TableSkeleton({
rows = 5,
columns = 4,
}: {
rows?: number;
columns?: number;
}) {
return (
<table className="w-full">
<thead>
<tr className="border-b">
{Array.from({ length: columns }).map((_, index) => (
<th key={index} className="py-3 px-6 text-left">
<Skeleton variant="text" width="60%" />
</th>
))}
</tr>
</thead>
<tbody>
{Array.from({ length: rows }).map((_, index) => (
<TableRowSkeleton key={index} columns={columns} />
))}
</tbody>
</table>
);
}
/**
* Order Card Skeleton
*/
export function OrderCardSkeleton() {
return (
<div className="bg-white rounded-lg shadow p-6 space-y-4">
<div className="flex justify-between">
<Skeleton variant="text" width={120} />
<Skeleton variant="rectangular" width={80} height={24} className="rounded-full" />
</div>
<div className="space-y-2">
<Skeleton variant="text" width="80%" />
<Skeleton variant="text" width="60%" />
</div>
<div className="flex gap-2">
<Skeleton variant="rectangular" width={80} height={32} />
<Skeleton variant="rectangular" width={80} height={32} />
</div>
</div>
);
}
/**
* Page Header Skeleton
*/
export function PageHeaderSkeleton() {
return (
<div className="space-y-2 mb-8">
<Skeleton variant="text" width={300} height={32} />
<Skeleton variant="text" width={200} />
</div>
);
}
/**
* Form Skeleton
*/
export function FormSkeleton({ fields = 4 }: { fields?: number }) {
return (
<div className="space-y-6">
{Array.from({ length: fields }).map((_, index) => (
<div key={index} className="space-y-2">
<Skeleton variant="text" width={100} />
<Skeleton variant="rectangular" height={40} className="w-full" />
</div>
))}
<Skeleton variant="rectangular" width={120} height={40} />
</div>
);
}