Skip to content

Commit 2ce2d05

Browse files
bteaautofix-ci[bot]ghostdevv
authored
feat: update versions page download count tooltip/title (npmx-dev#2695)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Willow (GHOST) <git@willow.sh>
1 parent da29a90 commit 2ce2d05

5 files changed

Lines changed: 40 additions & 12 deletions

File tree

app/pages/package/[[org]]/[name]/versions.vue

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ const groupDownloadsMap = computed(() => {
119119
return map
120120
})
121121
122-
function getDownloadsAriaLabel(downloads: number): string {
123-
return `${numberFormatter.value.format(downloads)} ${t('package.downloads.title')}`
122+
function getDownloadsAriaLabel(downloads: number, version: string): string {
123+
return `${numberFormatter.value.format(downloads)} ${t('package.downloads.version_distribution_title', { version })}`
124124
}
125125
126126
// ─── Phase 2: full metadata (fired automatically after phase 1 completes) ────
@@ -374,9 +374,19 @@ const flatItems = computed<FlatItem[]>(() => {
374374
<span
375375
v-if="getVersionDownloads(latestTagRow!.version)"
376376
class="w-28 grid grid-flow-col auto-cols-max items-center gap-1 text-xs text-fg-muted tabular-nums justify-end"
377-
:aria-label="getDownloadsAriaLabel(getVersionDownloads(latestTagRow!.version)!)"
377+
:aria-label="
378+
getDownloadsAriaLabel(
379+
getVersionDownloads(latestTagRow!.version)!,
380+
latestTagRow!.version,
381+
)
382+
"
378383
dir="ltr"
379-
:title="getDownloadsAriaLabel(getVersionDownloads(latestTagRow!.version)!)"
384+
:title="
385+
getDownloadsAriaLabel(
386+
getVersionDownloads(latestTagRow!.version)!,
387+
latestTagRow!.version,
388+
)
389+
"
380390
>
381391
<span>{{ numberFormatter.format(getVersionDownloads(latestTagRow!.version)!) }}</span>
382392
<span class="i-lucide:chart-line" aria-hidden="true"></span>
@@ -443,9 +453,9 @@ const flatItems = computed<FlatItem[]>(() => {
443453
<span
444454
v-if="getVersionDownloads(row.version)"
445455
class="w-28 grid grid-flow-col auto-cols-max items-center justify-end gap-1 text-xs text-fg-muted tabular-nums shrink-0 relative z-10"
446-
:aria-label="getDownloadsAriaLabel(getVersionDownloads(row.version)!)"
456+
:aria-label="getDownloadsAriaLabel(getVersionDownloads(row.version)!, row.version)"
447457
dir="ltr"
448-
:title="getDownloadsAriaLabel(getVersionDownloads(row.version)!)"
458+
:title="getDownloadsAriaLabel(getVersionDownloads(row.version)!, row.version)"
449459
>
450460
<span>{{ numberFormatter.format(getVersionDownloads(row.version)!) }}</span>
451461
<span class="i-lucide:chart-line" aria-hidden="true"></span>
@@ -533,9 +543,13 @@ const flatItems = computed<FlatItem[]>(() => {
533543
<span
534544
v-if="groupDownloadsMap.has(item.groupKey)"
535545
class="ms-auto w-28 grid grid-flow-col auto-cols-max items-center justify-end gap-1 text-xs text-fg-muted tabular-nums shrink-0"
536-
:aria-label="getDownloadsAriaLabel(groupDownloadsMap.get(item.groupKey)!)"
546+
:aria-label="
547+
getDownloadsAriaLabel(groupDownloadsMap.get(item.groupKey)!, item.label)
548+
"
537549
dir="ltr"
538-
:title="getDownloadsAriaLabel(groupDownloadsMap.get(item.groupKey)!)"
550+
:title="
551+
getDownloadsAriaLabel(groupDownloadsMap.get(item.groupKey)!, item.label)
552+
"
539553
>
540554
<span>{{
541555
numberFormatter.format(groupDownloadsMap.get(item.groupKey)!)
@@ -624,8 +638,12 @@ const flatItems = computed<FlatItem[]>(() => {
624638
<span
625639
v-if="getVersionDownloads(item.version)"
626640
class="w-28 grid grid-flow-col auto-cols-max items-center justify-end gap-1 text-xs text-fg-muted tabular-nums shrink-0 relative z-10"
627-
:aria-label="getDownloadsAriaLabel(getVersionDownloads(item.version)!)"
628-
:title="getDownloadsAriaLabel(getVersionDownloads(item.version)!)"
641+
:aria-label="
642+
getDownloadsAriaLabel(getVersionDownloads(item.version)!, item.version)
643+
"
644+
:title="
645+
getDownloadsAriaLabel(getVersionDownloads(item.version)!, item.version)
646+
"
629647
dir="ltr"
630648
>
631649
<span>{{
@@ -673,9 +691,13 @@ const flatItems = computed<FlatItem[]>(() => {
673691
<span
674692
v-if="groupDownloadsMap.has(item.groupKey)"
675693
class="ms-auto w-28 grid grid-flow-col auto-cols-max items-center justify-end gap-1 text-xs text-fg-muted tabular-nums shrink-0"
676-
:aria-label="getDownloadsAriaLabel(groupDownloadsMap.get(item.groupKey)!)"
694+
:aria-label="
695+
getDownloadsAriaLabel(groupDownloadsMap.get(item.groupKey)!, item.label)
696+
"
677697
dir="ltr"
678-
:title="getDownloadsAriaLabel(groupDownloadsMap.get(item.groupKey)!)"
698+
:title="
699+
getDownloadsAriaLabel(groupDownloadsMap.get(item.groupKey)!, item.label)
700+
"
679701
>
680702
<span>{{ numberFormatter.format(groupDownloadsMap.get(item.groupKey)!) }}</span>
681703
<span class="i-lucide:chart-line" aria-hidden="true"></span>

i18n/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,7 @@
716716
},
717717
"downloads": {
718718
"title": "Weekly Downloads",
719+
"version_distribution_title": "weekly downloads for version {version}",
719720
"community_distribution": "View community adoption distribution",
720721
"subtitle": "Across all versions",
721722
"sparkline_nav_hint": "Use ← →"

i18n/locales/zh-CN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@
711711
},
712712
"downloads": {
713713
"title": "每周下载量",
714+
"version_distribution_title": "{version} 版本的每周下载量",
714715
"community_distribution": "查看社区采用分布",
715716
"subtitle": "涵盖所有版本",
716717
"sparkline_nav_hint": "使用 ← →"

i18n/locales/zh-TW.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@
659659
},
660660
"downloads": {
661661
"title": "每週下載量",
662+
"version_distribution_title": "{version} 每週下載量",
662663
"community_distribution": "檢視社群採用分布",
663664
"subtitle": "所有版本",
664665
"sparkline_nav_hint": "使用 ← →"

i18n/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2152,6 +2152,9 @@
21522152
"title": {
21532153
"type": "string"
21542154
},
2155+
"version_distribution_title": {
2156+
"type": "string"
2157+
},
21552158
"community_distribution": {
21562159
"type": "string"
21572160
},

0 commit comments

Comments
 (0)