Skip to content

Commit 494b3d2

Browse files
Adebesin-Cellclaude
andcommitted
feat: add versions to all tiers, sort by downloads, add ./npmx branding
- Show version badges on full/compact tiers (after package name) - Show inline version text on grid tier - Fetch versions for all tiers (not just full) - Sort packages by downloads descending for readability - Add ./npmx branding in bottom-right corner - Fix icon outline by using explicit linear-gradient Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 63db575 commit 494b3d2

File tree

1 file changed

+48
-26
lines changed

1 file changed

+48
-26
lines changed

app/components/OgImage/Compare.vue

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,18 @@ if (layoutTier.value !== 'summary') {
7070
const results = await Promise.all(
7171
displayPackages.value.map(async (name, index) => {
7272
const encoded = encodePackageName(name)
73-
const needsVersion = layoutTier.value === 'full'
7473
const [dlData, pkgData] = await Promise.all([
7574
$fetch<{ downloads: number }>(
7675
`https://api.npmjs.org/downloads/point/last-week/${encoded}`,
7776
{ timeout: FETCH_TIMEOUT_MS },
7877
).catch(() => null),
79-
needsVersion
80-
? $fetch<{ 'dist-tags'?: { latest?: string } }>(
81-
`https://registry.npmjs.org/${encoded}`,
82-
{
83-
timeout: FETCH_TIMEOUT_MS,
84-
headers: { Accept: 'application/vnd.npm.install-v1+json' },
85-
},
86-
).catch(() => null)
87-
: Promise.resolve(null),
78+
$fetch<{ 'dist-tags'?: { latest?: string } }>(
79+
`https://registry.npmjs.org/${encoded}`,
80+
{
81+
timeout: FETCH_TIMEOUT_MS,
82+
headers: { Accept: 'application/vnd.npm.install-v1+json' },
83+
},
84+
).catch(() => null),
8885
])
8986
return {
9087
name,
@@ -164,8 +161,8 @@ const summaryRemainder = computed(() =>
164161
<!-- Icon + title row -->
165162
<div class="flex items-start gap-4">
166163
<div
167-
class="flex items-center justify-center w-16 h-16 p-3.5 rounded-xl shadow-lg bg-gradient-to-tr from-[#3b82f6]"
168-
:style="{ backgroundColor: primaryColor }"
164+
class="flex items-center justify-center w-16 h-16 p-3.5 rounded-xl shadow-lg"
165+
:style="{ background: `linear-gradient(to top right, #3b82f6, ${primaryColor})` }"
169166
>
170167
<svg
171168
width="36"
@@ -215,9 +212,6 @@ const summaryRemainder = computed(() =>
215212
>
216213
{{ pkg.name }}
217214
</span>
218-
<span class="text-3xl font-bold text-[#fafafa]">
219-
{{ formatDownloads(pkg.downloads) }}/wk
220-
</span>
221215
<span
222216
v-if="pkg.version"
223217
class="text-lg px-2 py-0.5 rounded-md border"
@@ -229,6 +223,9 @@ const summaryRemainder = computed(() =>
229223
>
230224
{{ pkg.version }}
231225
</span>
226+
<span class="text-3xl font-bold text-[#fafafa]">
227+
{{ formatDownloads(pkg.downloads) }}/wk
228+
</span>
232229
</div>
233230
<div
234231
class="h-6 rounded-md"
@@ -250,6 +247,17 @@ const summaryRemainder = computed(() =>
250247
>
251248
{{ pkg.name }}
252249
</span>
250+
<span
251+
v-if="pkg.version"
252+
class="text-sm px-1.5 py-0.5 rounded border"
253+
:style="{
254+
color: pkg.color,
255+
backgroundColor: pkg.color + '10',
256+
borderColor: pkg.color + '30',
257+
}"
258+
>
259+
{{ pkg.version }}
260+
</span>
253261
<span class="text-xl font-bold text-[#fafafa]">
254262
{{ formatDownloads(pkg.downloads) }}/wk
255263
</span>
@@ -282,17 +290,23 @@ const summaryRemainder = computed(() =>
282290
width: gridItemWidth,
283291
}"
284292
>
285-
<span
286-
class="font-semibold tracking-tight"
287-
:style="{
288-
fontSize: '18px',
289-
overflow: 'hidden',
290-
textOverflow: 'ellipsis',
291-
whiteSpace: 'nowrap',
292-
color: pkg.color,
293-
}"
294-
>{{ pkg.name }}</span
295-
>
293+
<span class="flex items-baseline gap-1.5">
294+
<span
295+
class="font-semibold tracking-tight"
296+
:style="{
297+
fontSize: '18px',
298+
overflow: 'hidden',
299+
textOverflow: 'ellipsis',
300+
whiteSpace: 'nowrap',
301+
color: pkg.color,
302+
}"
303+
>{{ pkg.name }}</span
304+
>
305+
<span
306+
v-if="pkg.version"
307+
class="text-xs text-[#525252]"
308+
>{{ pkg.version }}</span>
309+
</span>
296310
<span class="flex items-baseline gap-0.5">
297311
<span class="text-2xl font-bold text-[#e5e5e5]">{{
298312
formatDownloads(pkg.downloads)
@@ -324,6 +338,14 @@ const summaryRemainder = computed(() =>
324338
</div>
325339
</div>
326340

341+
<!-- Branding -->
342+
<div
343+
class="absolute bottom-6 right-20 text-lg font-semibold tracking-tight text-[#525252]"
344+
style="font-family: 'Geist Mono', sans-serif"
345+
>
346+
<span :style="{ color: primaryColor }" class="opacity-80 tracking-[-0.1em]">./</span>npmx
347+
</div>
348+
327349
<div
328350
class="absolute -top-32 -inset-ie-32 w-[550px] h-[550px] rounded-full blur-3xl"
329351
:style="{ backgroundColor: primaryColor + '10' }"

0 commit comments

Comments
 (0)