Skip to content

Commit f518e4a

Browse files
Adebesin-Cellclaude
andcommitted
fix: normalise array package input and fix zero-download bar width
- Apply trim/filter to string[] input, not just comma-separated strings - Return 0% width for zero-download entries instead of a misleading 5% - Cap bar width at 100% Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 28ca4d3 commit f518e4a

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

app/components/OgImage/Compare.vue

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,9 @@ const ACCENT_COLORS = ['#60a5fa', '#f472b6', '#34d399', '#fbbf24']
1919
2020
const displayPackages = computed(() => {
2121
const raw = props.packages
22-
const list =
23-
typeof raw === 'string'
24-
? raw
25-
.split(',')
26-
.map(p => p.trim())
27-
.filter(Boolean)
28-
: raw
22+
const list = (typeof raw === 'string' ? raw.split(',') : raw)
23+
.map(p => p.trim())
24+
.filter(Boolean)
2925
return list.slice(0, 4)
3026
})
3127
@@ -84,8 +80,9 @@ function formatDownloads(n: number): string {
8480
8581
// Bar width as percentage string (max 100%)
8682
function barPct(downloads: number): string {
83+
if (downloads <= 0) return '0%'
8784
const pct = (downloads / maxDownloads.value) * 100
88-
return `${Math.max(pct, 5)}%`
85+
return `${Math.min(100, Math.max(pct, 5))}%`
8986
}
9087
</script>
9188

0 commit comments

Comments
 (0)