forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChartSkeleton.tsx
More file actions
63 lines (59 loc) 路 2.05 KB
/
Copy pathChartSkeleton.tsx
File metadata and controls
63 lines (59 loc) 路 2.05 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
const shimmer = `
@keyframes shimmer {
0% { background-position: -400px 0; }
100% { background-position: 400px 0; }
}
.skeleton-shimmer {
background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
background-size: 800px 100%;
animation: shimmer 1.4s infinite linear;
}
`;
function ShimmerBlock({ height, width, radius = 8 }: { height: number; width?: number | string; radius?: number }) {
return <div className="skeleton-shimmer" style={{ height, width: width ?? '100%', borderRadius: radius }} />;
}
/** Skeleton for chart panels */
export default function ChartSkeleton() {
return (
<>
<style>{shimmer}</style>
<div style={{ display: 'flex', flexDirection: 'column', gap: 14 }}>
<ShimmerBlock height={18} width={180} radius={999} />
<ShimmerBlock height={220} radius={18} />
</div>
</>
);
}
/** Skeleton for KPI cards */
export function KPICardSkeleton() {
return (
<>
<style>{shimmer}</style>
<div style={{ borderRadius: 16, padding: '24px 28px', border: '1px solid #e5e7eb', display: 'flex', flexDirection: 'column', gap: 14 }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<ShimmerBlock height={12} width={80} radius={999} />
<ShimmerBlock height={36} width={36} radius={10} />
</div>
<ShimmerBlock height={40} width={120} radius={8} />
<ShimmerBlock height={14} width={100} radius={999} />
</div>
</>
);
}
/** Skeleton for table rows */
export function TableSkeleton({ rows = 5 }: { rows?: number }) {
return (
<>
<style>{shimmer}</style>
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
<ShimmerBlock height={16} width={140} radius={999} />
{Array.from({ length: rows }).map((_, i) => (
<div key={i} style={{ display: 'flex', gap: 12 }}>
<ShimmerBlock height={14} width="60%" radius={999} />
<ShimmerBlock height={14} width="30%" radius={999} />
</div>
))}
</div>
</>
);
}