Skip to content

Commit 87fbffd

Browse files
committed
Show "No download data available" instead of hiding the entire component
1 parent c64c0b8 commit 87fbffd

2 files changed

Lines changed: 39 additions & 32 deletions

File tree

app/components/Package/WeeklyDownloadStats.vue

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ const config = computed(() => {
205205
</script>
206206

207207
<template>
208-
<div v-if="isLoadingWeeklyDownloads || hasWeeklyDownloads" class="space-y-8">
208+
<div class="space-y-8">
209209
<CollapsibleSection id="downloads" :title="$t('package.downloads.title')">
210210
<template #actions>
211211
<button
@@ -221,39 +221,44 @@ const config = computed(() => {
221221
</template>
222222

223223
<div class="w-full overflow-hidden">
224-
<ClientOnly>
225-
<VueUiSparkline class="w-full max-w-xs" :dataset :config>
226-
<template #skeleton>
227-
<!-- This empty div overrides the default built-in scanning animation on load -->
228-
<div />
229-
</template>
230-
</VueUiSparkline>
231-
<template #fallback>
232-
<!-- Skeleton matching sparkline layout: title row + chart with data label -->
233-
<div class="min-h-[75.195px]">
234-
<!-- Title row: date range (24px height) -->
235-
<div class="h-6 flex items-center ps-3">
236-
<SkeletonInline class="h-3 w-36" />
237-
</div>
238-
<!-- Chart area: data label left, sparkline right -->
239-
<div class="aspect-[500/80] flex items-center">
240-
<!-- Data label (covers ~42% width) -->
241-
<div class="w-[42%] flex items-center ps-0.5">
242-
<SkeletonInline class="h-7 w-24" />
224+
<template v-if="isLoadingWeeklyDownloads || hasWeeklyDownloads">
225+
<ClientOnly>
226+
<VueUiSparkline class="w-full max-w-xs" :dataset :config>
227+
<template #skeleton>
228+
<!-- This empty div overrides the default built-in scanning animation on load -->
229+
<div />
230+
</template>
231+
</VueUiSparkline>
232+
<template #fallback>
233+
<!-- Skeleton matching sparkline layout: title row + chart with data label -->
234+
<div class="min-h-[75.195px]">
235+
<!-- Title row: date range (24px height) -->
236+
<div class="h-6 flex items-center ps-3">
237+
<SkeletonInline class="h-3 w-36" />
243238
</div>
244-
<!-- Sparkline area (~58% width) -->
245-
<div class="flex-1 flex items-end gap-0.5 h-4/5 pe-3">
246-
<SkeletonInline
247-
v-for="i in 16"
248-
:key="i"
249-
class="flex-1 rounded-sm"
250-
:style="{ height: `${25 + ((i * 7) % 50)}%` }"
251-
/>
239+
<!-- Chart area: data label left, sparkline right -->
240+
<div class="aspect-[500/80] flex items-center">
241+
<!-- Data label (covers ~42% width) -->
242+
<div class="w-[42%] flex items-center ps-0.5">
243+
<SkeletonInline class="h-7 w-24" />
244+
</div>
245+
<!-- Sparkline area (~58% width) -->
246+
<div class="flex-1 flex items-end gap-0.5 h-4/5 pe-3">
247+
<SkeletonInline
248+
v-for="i in 16"
249+
:key="i"
250+
class="flex-1 rounded-sm"
251+
:style="{ height: `${25 + ((i * 7) % 50)}%` }"
252+
/>
253+
</div>
252254
</div>
253255
</div>
254-
</div>
255-
</template>
256-
</ClientOnly>
256+
</template>
257+
</ClientOnly>
258+
</template>
259+
<p v-else class="py-2 text-sm font-mono text-fg-subtle">
260+
{{ $t('package.downloads.no_data') }}
261+
</p>
257262
</div>
258263
</CollapsibleSection>
259264
</div>

test/nuxt/components/PackageWeeklyDownloadStats.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ describe('PackageWeeklyDownloadStats', () => {
3939
props: baseProps,
4040
})
4141

42-
expect(component.text()).not.toContain('Weekly Downloads')
42+
expect(component.text()).toContain('Weekly Downloads')
43+
expect(component.text()).toContain('No download data available')
4344
})
4445

4546
it('shows the section when weekly downloads exist', async () => {
@@ -59,5 +60,6 @@ describe('PackageWeeklyDownloadStats', () => {
5960
})
6061

6162
expect(component.text()).toContain('Weekly Downloads')
63+
expect(component.text()).not.toContain('No download data available')
6264
})
6365
})

0 commit comments

Comments
 (0)