Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions app/components/Package/TableRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ const isSelected = computed<boolean>(() => {
return isPackageSelected(props.result.package.name)
})
function formatDownloads(count?: number): string {
if (count === undefined) return '-'
if (count >= 1_000_000) return `${(count / 1_000_000).toFixed(1)}M`
if (count >= 1_000) return `${(count / 1_000).toFixed(1)}K`
return count.toString()
}
function formatScore(value?: number): string {
if (value === undefined || value === 0) return '-'
return Math.round(value * 100).toString()
Expand All @@ -44,6 +37,8 @@ const allMaintainersText = computed(() => {
if (!pkg.value.maintainers?.length) return ''
return pkg.value.maintainers.map(m => m.name || m.email).join(', ')
})
const compactNumberFormatter = useCompactNumberFormatter()
</script>

<template>
Expand Down Expand Up @@ -89,7 +84,11 @@ const allMaintainersText = computed(() => {
v-if="isColumnVisible('downloads')"
class="py-2 px-3 font-mono text-xs text-fg-muted text-end tabular-nums"
>
{{ formatDownloads(result.downloads?.weekly) }}
{{
result.downloads?.weekly !== undefined
? compactNumberFormatter.format(result.downloads.weekly)
: '-'
}}
</td>

<!-- Updated -->
Expand Down
4 changes: 2 additions & 2 deletions app/components/PaginationControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function handlePageSizeChange(event: Event) {
@change="handlePageSizeChange"
:items="
PAGE_SIZE_OPTIONS.map(size => ({
label: $t('filters.pagination.per_page', { count: size }),
label: $t('filters.pagination.per_page', { count: $n(size) }),
value: String(size),
}))
"
Expand Down Expand Up @@ -207,7 +207,7 @@ function handlePageSizeChange(event: Event) {
:aria-current="page === currentPage ? 'page' : undefined"
@click="goToPage(page)"
>
{{ page }}
{{ $n(page) }}
</button>
</template>

Expand Down
2 changes: 1 addition & 1 deletion app/pages/search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ onBeforeUnmount(() => {
$t(
'filters.count.showing_paginated',
{
pageSize: Math.min(preferredPageSize, effectiveTotal),
pageSize: $n(Math.min(preferredPageSize, effectiveTotal)),
count: $n(effectiveTotal),
},
effectiveTotal,
Expand Down
Loading