|
| 1 | +/** |
| 2 | + * KycFormSkeleton |
| 3 | + * |
| 4 | + * Server-safe Suspense fallback rendered while the KycSubmissionForm client |
| 5 | + * bundle is streaming in. Uses plain CSS classes (no framer-motion, no hooks) |
| 6 | + * so it is safe to render in a Server Component or as a Suspense boundary |
| 7 | + * fallback. |
| 8 | + * |
| 9 | + * Structure mirrors the real form so the layout shift on hydration is minimal: |
| 10 | + * - Progress bar row |
| 11 | + * - Step indicator dots |
| 12 | + * - Skeleton field rows (title + 4 fields) |
| 13 | + * - Navigation button row |
| 14 | + */ |
| 15 | + |
| 16 | +import React from "react"; |
| 17 | + |
| 18 | +// ── Shimmer bone ────────────────────────────────────────────────────────────── |
| 19 | + |
| 20 | +function Bone({ className = "" }: { className?: string }) { |
| 21 | + return ( |
| 22 | + <div |
| 23 | + className={`kyc-shimmer rounded-lg ${className}`} |
| 24 | + aria-hidden="true" |
| 25 | + /> |
| 26 | + ); |
| 27 | +} |
| 28 | + |
| 29 | +// ── Skeleton step dot ───────────────────────────────────────────────────────── |
| 30 | + |
| 31 | +function StepDot({ active }: { active: boolean }) { |
| 32 | + return ( |
| 33 | + <div |
| 34 | + className={`h-2 flex-1 rounded-full ${ |
| 35 | + active ? "bg-pluto-600 dark:bg-pluto-400" : "bg-pluto-100 dark:bg-pluto-800" |
| 36 | + }`} |
| 37 | + aria-hidden="true" |
| 38 | + /> |
| 39 | + ); |
| 40 | +} |
| 41 | + |
| 42 | +// ── Main skeleton ───────────────────────────────────────────────────────────── |
| 43 | + |
| 44 | +export default function KycFormSkeleton() { |
| 45 | + return ( |
| 46 | + <div |
| 47 | + className="w-full max-w-2xl mx-auto" |
| 48 | + role="status" |
| 49 | + aria-label="Loading KYC form…" |
| 50 | + aria-busy="true" |
| 51 | + data-testid="kyc-form-skeleton" |
| 52 | + > |
| 53 | + {/* sr-only label for screen readers */} |
| 54 | + <span className="sr-only">Loading KYC form…</span> |
| 55 | + |
| 56 | + <div className="rounded-3xl border border-pluto-100 bg-white p-6 shadow-lg sm:p-8 dark:border-pluto-800/60 dark:bg-pluto-900/80 space-y-6"> |
| 57 | + |
| 58 | + {/* ── Progress bar skeleton ─────────────────────────────────────── */} |
| 59 | + <div className="space-y-2" aria-hidden="true"> |
| 60 | + {/* "X of 4" label row */} |
| 61 | + <div className="flex items-center justify-between"> |
| 62 | + <Bone className="h-3 w-10" /> |
| 63 | + </div> |
| 64 | + {/* Step dots */} |
| 65 | + <div className="flex gap-1.5"> |
| 66 | + <StepDot active /> |
| 67 | + <StepDot active={false} /> |
| 68 | + <StepDot active={false} /> |
| 69 | + <StepDot active={false} /> |
| 70 | + </div> |
| 71 | + </div> |
| 72 | + |
| 73 | + {/* ── Step content skeleton ─────────────────────────────────────── */} |
| 74 | + <div className="space-y-4" aria-hidden="true"> |
| 75 | + {/* Section heading */} |
| 76 | + <Bone className="h-6 w-48" /> |
| 77 | + |
| 78 | + {/* Two-column name row */} |
| 79 | + <div className="grid grid-cols-1 gap-4 sm:grid-cols-2"> |
| 80 | + <div className="space-y-1.5"> |
| 81 | + <Bone className="h-3.5 w-20" /> |
| 82 | + <Bone className="h-11 w-full" /> |
| 83 | + </div> |
| 84 | + <div className="space-y-1.5"> |
| 85 | + <Bone className="h-3.5 w-20" /> |
| 86 | + <Bone className="h-11 w-full" /> |
| 87 | + </div> |
| 88 | + </div> |
| 89 | + |
| 90 | + {/* Full-width email row */} |
| 91 | + <div className="space-y-1.5"> |
| 92 | + <Bone className="h-3.5 w-16" /> |
| 93 | + <Bone className="h-11 w-full" /> |
| 94 | + </div> |
| 95 | + |
| 96 | + {/* Full-width date row */} |
| 97 | + <div className="space-y-1.5"> |
| 98 | + <Bone className="h-3.5 w-24" /> |
| 99 | + <Bone className="h-11 w-full" /> |
| 100 | + </div> |
| 101 | + </div> |
| 102 | + |
| 103 | + {/* ── Navigation button skeleton ────────────────────────────────── */} |
| 104 | + <div className="flex gap-3 pt-1" aria-hidden="true"> |
| 105 | + <Bone className="h-12 flex-1 rounded-xl" /> |
| 106 | + <Bone className="h-12 flex-1 rounded-xl" /> |
| 107 | + </div> |
| 108 | + </div> |
| 109 | + </div> |
| 110 | + ); |
| 111 | +} |
0 commit comments