Skip to content

Commit e4a5623

Browse files
committed
Show "No download data available" instead of hiding the entire component
1 parent 7719ed5 commit e4a5623

File tree

2 files changed

+39
-32
lines changed

2 files changed

+39
-32
lines changed

app/components/Package/WeeklyDownloadStats.vue

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

217217
<template>
218-
<div v-if="isLoadingWeeklyDownloads || hasWeeklyDownloads" class="space-y-8">
218+
<div class="space-y-8">
219219
<CollapsibleSection id="downloads" :title="$t('package.downloads.title')">
220220
<template #actions>
221221
<ButtonBase
@@ -231,39 +231,44 @@ const config = computed(() => {
231231
</template>
232232

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