ExplorerLoading.jsx 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import React from "react";
  2. import { Skeleton } from "@/components/ui/skeleton";
  3. /**
  4. * ExplorerLoading
  5. *
  6. * Loading placeholder for Explorer lists.
  7. * Supports a grid and a table-like variant.
  8. *
  9. * @param {{ variant?: "grid"|"table", count?: number }} props
  10. */
  11. export default function ExplorerLoading({ variant = "grid", count = 8 }) {
  12. const n = Number.isInteger(count) && count > 0 ? count : 8;
  13. if (variant === "table") {
  14. return (
  15. <div className="space-y-2">
  16. {Array.from({ length: n }).map((_, i) => (
  17. <div key={i} className="flex items-center justify-between gap-3">
  18. <div className="flex min-w-0 flex-1 items-center gap-2">
  19. <Skeleton className="h-4 w-4" />
  20. <Skeleton className="h-4 w-[60%]" />
  21. </div>
  22. <Skeleton className="h-8 w-24" />
  23. </div>
  24. ))}
  25. </div>
  26. );
  27. }
  28. return (
  29. <div className="grid grid-cols-2 gap-2 sm:grid-cols-3 md:grid-cols-4">
  30. {Array.from({ length: n }).map((_, i) => (
  31. <Skeleton key={i} className="h-10 w-full" />
  32. ))}
  33. </div>
  34. );
  35. }