File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { cn } from "@/lib/utils/cn"
2
+
3
+ // Pseudo-random list of skeleton widths for multiple lines
4
+ const widths = [
5
+ "w-1/3" ,
6
+ "w-1/5" ,
7
+ "w-4" ,
8
+ "w-1/4" ,
9
+ "w-1/2" ,
10
+ "w-1/6" ,
11
+ "w-8" ,
12
+ "w-1/4" ,
13
+ "w-1/3" ,
14
+ "w-1/5" ,
15
+ "w-1/6" ,
16
+ "w-4" ,
17
+ "w-1/4" ,
18
+ "w-1/3" ,
19
+ "w-1/2" ,
20
+ "w-1/5" ,
21
+ ]
22
+
23
+ const Skeleton = ( {
24
+ className,
25
+ ...props
26
+ } : React . HTMLAttributes < HTMLDivElement > ) => {
27
+ return (
28
+ < div
29
+ className = { cn ( "h-4 animate-pulse rounded bg-disabled" , className ) }
30
+ { ...props }
31
+ />
32
+ )
33
+ }
34
+
35
+ type SkeletonLinesProps = React . HTMLAttributes < HTMLDivElement > & {
36
+ noOfLines ?: number
37
+ }
38
+
39
+ const SkeletonLines = ( {
40
+ className,
41
+ noOfLines = 1 ,
42
+ ...props
43
+ } : SkeletonLinesProps ) => (
44
+ < div
45
+ className = { cn ( "flex !h-full flex-col gap-4 px-4 pt-8" , className ) }
46
+ { ...props }
47
+ >
48
+ { Array ( noOfLines )
49
+ . fill ( 0 )
50
+ . map ( ( _ , idx ) => (
51
+ < Skeleton key = { idx } className = { cn ( "h-3" , widths [ idx ] ) } />
52
+ ) ) }
53
+ </ div >
54
+ )
55
+
56
+ export { Skeleton , SkeletonLines }
You can’t perform that action at this time.
0 commit comments