|
| 1 | +import { Skeleton } from '@/components/ui/skeleton' |
| 2 | +import { cn } from '@/lib/utils' |
| 3 | + |
| 4 | +interface AdminPanelSkeletonProps { |
| 5 | + className?: string |
| 6 | + rowCount?: number |
| 7 | +} |
| 8 | + |
| 9 | +interface AdminAccordionSkeletonProps { |
| 10 | + itemCount: number |
| 11 | + showDescription?: boolean |
| 12 | +} |
| 13 | + |
| 14 | +export function AdminAccordionSkeleton({ itemCount, showDescription = false }: AdminAccordionSkeletonProps) { |
| 15 | + return ( |
| 16 | + <div className="grid gap-4" role="status" aria-label="Loading admin content"> |
| 17 | + {Array.from({ length: itemCount }).map((_, index) => ( |
| 18 | + <div |
| 19 | + key={index} |
| 20 | + className="flex h-18 items-center justify-between gap-4 rounded-xl border bg-background px-4" |
| 21 | + aria-hidden="true" |
| 22 | + > |
| 23 | + <div className="flex min-w-0 flex-1 items-center gap-3"> |
| 24 | + <Skeleton className={cn('shrink-0', showDescription ? 'size-9 rounded-lg' : 'size-4')} /> |
| 25 | + <div className="grid min-w-0 flex-1 gap-1.5"> |
| 26 | + <Skeleton className="h-4 w-36 max-w-full" /> |
| 27 | + {showDescription && <Skeleton className="h-3 w-80 max-w-full" />} |
| 28 | + </div> |
| 29 | + </div> |
| 30 | + <Skeleton className="size-6 shrink-0" /> |
| 31 | + </div> |
| 32 | + ))} |
| 33 | + </div> |
| 34 | + ) |
| 35 | +} |
| 36 | + |
| 37 | +export function AdminPanelSkeleton({ className, rowCount = 3 }: AdminPanelSkeletonProps) { |
| 38 | + return ( |
| 39 | + <section className={cn('grid gap-5 rounded-lg border bg-background p-6', className)} aria-hidden="true"> |
| 40 | + <div className="flex items-start justify-between gap-4"> |
| 41 | + <div className="grid min-w-0 flex-1 gap-2"> |
| 42 | + <Skeleton className="h-5 w-36 max-w-full" /> |
| 43 | + <Skeleton className="h-3 w-80 max-w-full" /> |
| 44 | + </div> |
| 45 | + <Skeleton className="size-9 shrink-0 rounded-md" /> |
| 46 | + </div> |
| 47 | + |
| 48 | + <div className="grid gap-4"> |
| 49 | + {Array.from({ length: rowCount }).map((_, index) => ( |
| 50 | + <div key={index} className="grid gap-2"> |
| 51 | + <Skeleton className="h-3 w-28" /> |
| 52 | + <Skeleton className="h-9 w-full" /> |
| 53 | + </div> |
| 54 | + ))} |
| 55 | + </div> |
| 56 | + </section> |
| 57 | + ) |
| 58 | +} |
| 59 | + |
| 60 | +export function AdminSettingsSkeleton({ sectionCount = 3 }: { sectionCount?: number }) { |
| 61 | + return ( |
| 62 | + <div className="grid gap-4" role="status" aria-label="Loading admin content"> |
| 63 | + {Array.from({ length: sectionCount }).map((_, index) => ( |
| 64 | + <AdminPanelSkeleton key={index} rowCount={index === 0 ? 2 : 3} /> |
| 65 | + ))} |
| 66 | + </div> |
| 67 | + ) |
| 68 | +} |
| 69 | + |
| 70 | +export function AdminCalendarSkeleton() { |
| 71 | + return ( |
| 72 | + <div |
| 73 | + className="grid min-h-[420px] grid-rows-[auto_1fr] gap-4 rounded-sm border bg-background p-4" |
| 74 | + role="status" |
| 75 | + aria-label="Loading calendar" |
| 76 | + > |
| 77 | + <div className="flex flex-wrap items-center justify-between gap-3" aria-hidden="true"> |
| 78 | + <Skeleton className="h-9 w-28" /> |
| 79 | + <Skeleton className="h-7 w-36" /> |
| 80 | + <div className="flex gap-2"> |
| 81 | + <Skeleton className="h-9 w-16" /> |
| 82 | + <Skeleton className="h-9 w-16" /> |
| 83 | + <Skeleton className="h-9 w-16" /> |
| 84 | + </div> |
| 85 | + </div> |
| 86 | + <div className="grid grid-cols-7 grid-rows-5 gap-px overflow-hidden rounded-sm bg-border" aria-hidden="true"> |
| 87 | + {Array.from({ length: 35 }).map((_, index) => ( |
| 88 | + <div key={index} className="bg-background p-2"> |
| 89 | + <Skeleton className="size-5 rounded-full" /> |
| 90 | + </div> |
| 91 | + ))} |
| 92 | + </div> |
| 93 | + </div> |
| 94 | + ) |
| 95 | +} |
| 96 | + |
| 97 | +export default function AdminPageSkeleton() { |
| 98 | + return ( |
| 99 | + <section className="grid min-w-0 gap-4"> |
| 100 | + <div className="grid gap-2" aria-hidden="true"> |
| 101 | + <Skeleton className="h-8 w-44" /> |
| 102 | + <Skeleton className="h-4 w-96 max-w-full" /> |
| 103 | + </div> |
| 104 | + <AdminSettingsSkeleton /> |
| 105 | + </section> |
| 106 | + ) |
| 107 | +} |
0 commit comments