forked from Lilly-Protocol/lily-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskeleton.tsx
More file actions
65 lines (59 loc) · 1.54 KB
/
Copy pathskeleton.tsx
File metadata and controls
65 lines (59 loc) · 1.54 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
import { cn } from "@/lib/utils";
interface SkeletonProps extends React.HTMLAttributes<HTMLDivElement> {
variant?: "default" | "text" | "avatar" | "card";
}
export function Skeleton({
className,
variant = "default",
...props
}: SkeletonProps) {
const base = "bg-[var(--color-line)] motion-reduce:animate-none animate-pulse rounded";
const variants = {
default: "",
text: "h-4 w-full",
avatar: "h-10 w-10 rounded-full",
card: "h-32 w-full rounded-lg",
};
return (
<div
className={cn(base, variants[variant], className)}
aria-hidden="true"
{...props}
/>
);
}
export function SkeletonText({
lines = 3,
className,
...props
}: { lines?: number } & Omit<SkeletonProps, "variant">) {
return (
<div className={cn("space-y-2", className)} {...props}>
{Array.from({ length: lines }).map((_, i) => (
<Skeleton
key={i}
variant="text"
className={i === lines - 1 ? "w-3/4" : undefined}
/>
))}
</div>
);
}
export function SkeletonCard({
className,
...props
}: Omit<SkeletonProps, "variant">) {
return (
<div className={cn("space-y-3 p-4", className)} {...props}>
<div className="flex items-center space-x-3">
<Skeleton variant="avatar" />
<div className="flex-1 space-y-2">
<Skeleton variant="text" className="w-1/2" />
<Skeleton variant="text" className="w-1/3" />
</div>
</div>
<Skeleton variant="text" />
<Skeleton variant="text" className="w-4/5" />
</div>
);
}