1 import { clx, Skeleton } from "@medusajs/ui"
2
3 interface PageSkeletonProps {
4 mainSections?: number
5 sidebarSections?: number
6 showJSON?: boolean
7 showMetadata?: boolean
8 }
9
10 export const PageSkeleton = ({
11 mainSections = 2,
12 sidebarSections = 1,
13 showJSON = false,
14 showMetadata = true,
15 }: PageSkeletonProps) => {
16 const showExtraData = showJSON || showMetadata
17
18 return (
19 <div className="flex flex-col gap-y-3">
20 <div className="flex flex-col gap-x-4 gap-y-3 xl:flex-row xl:items-start">
21 <div className="flex w-full flex-col gap-y-3">
22 {Array.from({ length: mainSections }, (_, i) => i).map((section) => {
23 return (
24 <Skeleton
25 key={section}
26 className={clx("h-full max-h-[460px] w-full rounded-lg", {
27 "max-h-[219px]": section === 0,
28 })}
29 />
30 )
31 })}
32 {showExtraData && (
33 <div className="hidden flex-col gap-y-3 xl:flex">
34 {showMetadata && (
35 <Skeleton className="h-[60px] w-full rounded-lg" />
36 )}
37 {showJSON && <Skeleton className="h-[60px] w-full rounded-lg" />}
38 </div>
39 )}
40 </div>
41 <div className="flex w-full max-w-[100%] flex-col gap-y-3 xl:mt-0 xl:max-w-[440px]">
42 {Array.from({ length: sidebarSections }, (_, i) => i).map(
43 (section) => {
44 return (
45 <Skeleton
46 key={section}
47 className={clx("h-full max-h-[320px] w-full rounded-lg", {
48 "max-h-[140px]": section === 0,
49 })}
50 />
51 )
52 }
53 )}
54 {showExtraData && (
55 <div className="flex flex-col gap-y-3 xl:hidden">
56 {showMetadata && (
57 <Skeleton className="h-[60px] w-full rounded-lg" />
58 )}
59 {showJSON && <Skeleton className="h-[60px] w-full rounded-lg" />}
60 </div>
61 )}
62 </div>
63 </div>
64 </div>
65 )
66 }