@@ -18,7 +18,13 @@ const NpmDownloadCounter = ({
1818 }
1919} ) => {
2020 const ref = useNpmDownloadCounter ( npmData )
21- return < span ref = { ref } style = { { fontVariantNumeric : 'tabular-nums' } } />
21+ // Provide initial SSR value, hook will update it on client
22+ const initialCount = npmData . totalDownloads ?? 0
23+ return (
24+ < span ref = { ref } style = { { fontVariantNumeric : 'tabular-nums' } } >
25+ { initialCount . toLocaleString ( ) }
26+ </ span >
27+ )
2228}
2329
2430function isValidMetric ( value : number | undefined | null ) : boolean {
@@ -144,9 +150,55 @@ function OssStatsContent({ library }: { library?: Library }) {
144150 )
145151}
146152
153+ function OssStatsSkeleton ( ) {
154+ return (
155+ < Card
156+ className = "relative p-8 grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-8 items-center
157+ justify-center xl:place-items-center rounded-[2rem]"
158+ >
159+ < div className = "flex gap-4 items-center" >
160+ < Download className = "text-2xl" />
161+ < div >
162+ < div className = "text-2xl font-bold opacity-80 h-7 w-24 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" />
163+ < div className = "text-sm opacity-60 font-medium italic" >
164+ NPM Downloads
165+ </ div >
166+ </ div >
167+ </ div >
168+ < div className = "flex gap-4 items-center" >
169+ < Star className = "text-2xl" />
170+ < div >
171+ < div className = "text-2xl font-bold opacity-80 h-7 w-20 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" />
172+ < div className = "text-sm opacity-60 font-medium italic -mt-1" >
173+ Stars on Github
174+ </ div >
175+ </ div >
176+ </ div >
177+ < div className = "flex gap-4 items-center" >
178+ < Users className = "text-2xl" />
179+ < div >
180+ < div className = "text-2xl font-bold opacity-80 h-7 w-16 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" />
181+ < div className = "text-sm opacity-60 font-medium italic -mt-1" >
182+ Contributors on GitHub
183+ </ div >
184+ </ div >
185+ </ div >
186+ < div className = "flex gap-4 items-center" >
187+ < Box className = "text-2xl" />
188+ < div >
189+ < div className = "text-2xl font-bold opacity-80 h-7 w-16 bg-gray-200 dark:bg-gray-700 rounded animate-pulse" />
190+ < div className = "text-sm opacity-60 font-medium italic -mt-1" >
191+ Dependents on GitHub
192+ </ div >
193+ </ div >
194+ </ div >
195+ </ Card >
196+ )
197+ }
198+
147199export default function OssStats ( { library } : { library ?: Library } ) {
148200 return (
149- < Suspense fallback = { < > < /> } >
201+ < Suspense fallback = { < OssStatsSkeleton /> } >
150202 < BlankErrorBoundary >
151203 < OssStatsContent library = { library } />
152204 </ BlankErrorBoundary >
0 commit comments