Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | /**
* Skeleton loading components for React frontend
* Used to show placeholder content while data is loading
*/
import { cn } from '../lib/utils'
/**
* Base skeleton element with pulse animation
*/
function Skeleton({ className }: { className?: string }) {
return (
<div className={cn('animate-pulse rounded bg-muted', className)} />
)
}
/**
* Skeleton for recipe cards in grids (AllRecipes, Search, Favorites)
*/
export function RecipeCardSkeleton() {
return (
<div className="overflow-hidden rounded-lg bg-card shadow-sm">
{/* Image placeholder */}
<Skeleton className="aspect-[4/3] rounded-none" />
{/* Content */}
<div className="p-3 space-y-2">
{/* Title */}
<Skeleton className="h-4 w-3/4" />
{/* Meta row */}
<div className="flex items-center gap-3">
<Skeleton className="h-3 w-16" />
<Skeleton className="h-3 w-12" />
</div>
</div>
</div>
)
}
/**
* Grid of recipe card skeletons
*/
export function RecipeGridSkeleton({ count = 8 }: { count?: number }) {
return (
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4">
{Array.from({ length: count }).map((_, i) => (
<RecipeCardSkeleton key={i} />
))}
</div>
)
}
/**
* Skeleton for collection cards
*/
export function CollectionCardSkeleton() {
return (
<div className="overflow-hidden rounded-lg bg-card p-4 shadow-sm">
{/* Icon placeholder */}
<Skeleton className="mb-8 h-12 w-12 rounded-lg" />
{/* Name */}
<Skeleton className="mb-2 h-5 w-3/4" />
{/* Count */}
<Skeleton className="h-4 w-16" />
</div>
)
}
/**
* Grid of collection card skeletons
*/
export function CollectionGridSkeleton({ count = 8 }: { count?: number }) {
return (
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4">
{Array.from({ length: count }).map((_, i) => (
<CollectionCardSkeleton key={i} />
))}
</div>
)
}
/**
* Full recipe detail page skeleton
*/
export function RecipeDetailSkeleton() {
return (
<div className="min-h-screen bg-background">
{/* Hero image skeleton */}
<div className="relative h-64 sm:h-80">
<Skeleton className="h-full w-full rounded-none" />
{/* Back button placeholder */}
<div className="absolute left-4 top-4">
<Skeleton className="h-10 w-10 rounded-full" />
</div>
{/* Title overlay placeholder */}
<div className="absolute bottom-4 left-4 right-4">
<Skeleton className="mb-2 h-7 w-3/4" />
<div className="flex gap-3">
<Skeleton className="h-4 w-16" />
<Skeleton className="h-4 w-24" />
</div>
</div>
{/* Action buttons placeholder */}
<div className="absolute bottom-4 right-4 flex gap-2">
<Skeleton className="h-10 w-10 rounded-full" />
<Skeleton className="h-10 w-10 rounded-full" />
<Skeleton className="h-10 w-20 rounded-full" />
</div>
</div>
{/* Meta info skeleton */}
<div className="border-b border-border px-4 py-4">
<div className="flex flex-wrap gap-4">
<Skeleton className="h-5 w-24" />
<Skeleton className="h-5 w-24" />
<Skeleton className="h-5 w-24" />
<Skeleton className="h-5 w-32" />
</div>
</div>
{/* Tabs skeleton */}
<div className="border-b border-border px-4">
<div className="flex gap-4 py-3">
<Skeleton className="h-5 w-20" />
<Skeleton className="h-5 w-20" />
<Skeleton className="h-5 w-16" />
<Skeleton className="h-5 w-12" />
</div>
</div>
{/* Content skeleton */}
<div className="px-4 py-6 space-y-4">
{Array.from({ length: 6 }).map((_, i) => (
<div key={i} className="flex items-start gap-3">
<Skeleton className="h-7 w-7 rounded-full shrink-0" />
<Skeleton className="h-5 flex-1" />
</div>
))}
</div>
</div>
)
}
/**
* Simple centered loading spinner
*/
export function LoadingSpinner({ className }: { className?: string }) {
return (
<div className={cn('flex items-center justify-center py-12', className)}>
<div className="h-8 w-8 animate-spin rounded-full border-4 border-muted border-t-primary" />
</div>
)
}
/**
* Loading state for list pages with optional message
*/
export function LoadingState({ message = 'Loading...' }: { message?: string }) {
return (
<div className="flex flex-col items-center justify-center py-12">
<div className="mb-3 h-8 w-8 animate-spin rounded-full border-4 border-muted border-t-primary" />
<span className="text-sm text-muted-foreground">{message}</span>
</div>
)
}
/**
* Search result card skeleton
*/
export function SearchResultSkeleton() {
return (
<div className="overflow-hidden rounded-lg bg-card shadow-sm">
{/* Image placeholder */}
<Skeleton className="aspect-[4/3] rounded-none" />
{/* Content */}
<div className="p-3 space-y-2">
{/* Title */}
<Skeleton className="h-4 w-3/4" />
{/* Meta */}
<Skeleton className="h-3 w-1/2" />
{/* Description */}
<Skeleton className="h-3 w-full" />
<Skeleton className="h-3 w-2/3" />
{/* Button */}
<Skeleton className="h-8 w-full mt-2" />
</div>
</div>
)
}
/**
* Grid of search result skeletons
*/
export function SearchGridSkeleton({ count = 6 }: { count?: number }) {
return (
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3">
{Array.from({ length: count }).map((_, i) => (
<SearchResultSkeleton key={i} />
))}
</div>
)
}
|