Skip to content

Commit ed347e0

Browse files
committed
Merge branch 'main' into feat-i18n/adding-dutch
2 parents 2d7ce67 + 04f3ab9 commit ed347e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+399
-165
lines changed

app/components/Compare/FacetBarChart.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,18 @@ const config = computed<VueUiHorizontalBarConfig>(() => {
220220
const name = datapoint?.name?.replace(/\n/g, '<br>')
221221
return `
222222
<div class="font-mono p-3 border border-border rounded-md bg-[var(--bg)]/10 backdrop-blur-md">
223-
<div class="flex items-center gap-2">
223+
<div class="grid grid-cols-[12px_minmax(0,1fr)_max-content] items-center gap-x-3">
224224
<div class="w-3 h-3">
225225
<svg viewBox="0 0 2 2" class="w-full h-full">
226226
<rect x="0" y="0" width="2" height="2" rx="0.3" fill="${datapoint?.color}" />
227227
</svg>
228228
</div>
229-
<span>${name}: ${(datapoint as VueUiHorizontalBarDatapoint).formattedValue ?? 0}</span>
229+
<span class="text-3xs uppercase tracking-wide text-[var(--fg)]/70 truncate">
230+
${name}
231+
</span>
232+
<span class="text-base text-[var(--fg)] font-mono tabular-nums text-end">
233+
${(datapoint as VueUiHorizontalBarDatapoint).formattedValue ?? 0}
234+
</span>
230235
</div>
231236
</div>
232237
`

app/components/Package/TrendsChart.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type {
2020
import { DATE_INPUT_MAX } from '~/utils/input'
2121
import { applyDataCorrection } from '~/utils/chart-data-correction'
2222
import { applyBlocklistCorrection, getAnomaliesForPackages } from '~/utils/download-anomalies'
23-
import { copyAltTextForTrendLineChart, sanitise, loadFile } from '~/utils/charts'
23+
import { copyAltTextForTrendLineChart, sanitise, loadFile, applyEllipsis } from '~/utils/charts'
2424
2525
import('vue-data-ui/style.css')
2626
@@ -215,7 +215,7 @@ function formatXyDataset(
215215
const temperatureColors = lightColor ? [lightColor, accent.value] : undefined
216216
217217
const datasetItem: VueUiXyDatasetItem = {
218-
name: seriesName,
218+
name: applyEllipsis(seriesName, 32),
219219
type: 'line',
220220
series: dataset.map(d => d.value),
221221
color: accent.value,
@@ -1050,7 +1050,7 @@ const chartData = computed<{
10501050
.filter(index => index !== -1)
10511051
10521052
const item: VueUiXyDatasetItem = {
1053-
name: pkg,
1053+
name: applyEllipsis(pkg, 32),
10541054
type: 'line',
10551055
series,
10561056
dashIndices,
@@ -1111,10 +1111,10 @@ function buildExportFilename(extension: string): string {
11111111
11121112
if (!isMultiPackageMode.value) {
11131113
const name = effectivePackageNames.value[0] ?? props.packageName ?? 'package'
1114-
return `${sanitise(name)}-${g}_${range}.${extension}`
1114+
return `${sanitise(applyEllipsis(name, 32))}-${g}_${range}.${extension}`
11151115
}
11161116
1117-
const names = effectivePackageNames.value
1117+
const names = effectivePackageNames.value.map(name => applyEllipsis(name, 32))
11181118
const label = names.length === 1 ? names[0] : names.join('_')
11191119
return `${sanitise(label ?? '')}-${g}_${range}.${extension}`
11201120
}

app/components/Package/VersionDistribution.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
drawNpmxLogoAndTaglineWatermark,
1010
} from '~/composables/useChartWatermark'
1111
import TooltipApp from '~/components/Tooltip/App.vue'
12-
import { copyAltTextForVersionsBarChart, sanitise, loadFile } from '~/utils/charts'
12+
import { copyAltTextForVersionsBarChart, sanitise, loadFile, applyEllipsis } from '~/utils/charts'
1313
1414
import('vue-data-ui/style.css')
1515
@@ -131,7 +131,7 @@ const dateRangeLabel = computed(() => {
131131
function buildExportFilename(extension: string): string {
132132
const range = dateRangeLabel.value.replaceAll(' ', '_').replaceAll(',', '')
133133
134-
const label = props.packageName
134+
const label = applyEllipsis(props.packageName, 32)
135135
return `${sanitise(label ?? '')}_${range}.${extension}`
136136
}
137137
@@ -141,7 +141,7 @@ const xyDataset = computed<VueUiXyDatasetItem[]>(() => {
141141
142142
return [
143143
{
144-
name: props.packageName,
144+
name: applyEllipsis(props.packageName, 32),
145145
series: chartDataset.value.map(item => item.downloads),
146146
type: 'bar' as const,
147147
color: accent.value,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Return the text "see on {git provider}" based on the given provider
3+
*/
4+
export function useViewOnGitProvider(
5+
provider: MaybeRefOrGetter<ProviderId | (string & {}) | null | undefined>,
6+
) {
7+
const { t } = useI18n()
8+
return computed(() => {
9+
const uProvider = toValue(provider)
10+
if (!uProvider) {
11+
return t('common.view_on.git_repo')
12+
}
13+
switch (uProvider) {
14+
case 'github':
15+
return t('common.view_on.github')
16+
case 'gitlab':
17+
return t('common.view_on.gitlab')
18+
case 'bitbucket':
19+
return t('common.view_on.bitbucket')
20+
case 'gitea':
21+
return t('common.view_on.gitea')
22+
case 'forgejo':
23+
return t('common.view_on.forgejo')
24+
case 'codeberg':
25+
return t('common.view_on.codeberg')
26+
case 'sourcehut':
27+
return t('common.view_on.sourcehut')
28+
case 'gitee':
29+
return t('common.view_on.gitee')
30+
case 'tangled':
31+
return t('common.view_on.tangled')
32+
case 'radicle':
33+
return t('common.view_on.radicle')
34+
case 'git':
35+
return t('common.view_on.git_repo')
36+
}
37+
38+
if (import.meta.dev) {
39+
// oxlint-disable-next-line no-console
40+
console.warn(`missing '${uProvider}' provider, add it to shared/utils/git-providers.ts!`)
41+
}
42+
return t('common.view_on.git_repo')
43+
})
44+
}

app/pages/org/[org].vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ defineOgImageComponent('Default', {
175175
target="_blank"
176176
rel="noopener noreferrer"
177177
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
178-
:title="$t('common.view_on_npm')"
178+
:title="$t('common.view_on.npm')"
179179
>
180180
<span class="i-simple-icons:npm w-4 h-4" aria-hidden="true" />
181181
npm

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { useModal } from '~/composables/useModal'
2121
import { useAtproto } from '~/composables/atproto/useAtproto'
2222
import { togglePackageLike } from '~/utils/atproto/likes'
2323
import { useInstallSizeDiff } from '~/composables/useInstallSizeDiff'
24+
import { useViewOnGitProvider } from '~/composables/useViewOnGitProvider'
2425
import type { RouteLocationRaw } from 'vue-router'
2526
2627
defineOgImageComponent('Package', {
@@ -106,6 +107,11 @@ const navExtraOffsetStyle = computed(() => ({
106107
107108
const { packageName, requestedVersion, orgName } = usePackageRoute()
108109
110+
const { data: resolvedVersion, status: resolvedStatus } = await useResolvedVersion(
111+
packageName,
112+
requestedVersion,
113+
)
114+
109115
if (import.meta.server) {
110116
assertValidPackageName(packageName.value)
111117
}
@@ -114,7 +120,7 @@ if (import.meta.server) {
114120
const { data: readmeData } = useLazyFetch<ReadmeResponse>(
115121
() => {
116122
const base = `/api/registry/readme/${packageName.value}`
117-
const version = requestedVersion.value
123+
const version = resolvedVersion.value
118124
return version ? `${base}/v/${version}` : base
119125
},
120126
{
@@ -150,7 +156,7 @@ const {
150156
} = useLazyFetch<ReadmeMarkdownResponse>(
151157
() => {
152158
const base = `/api/registry/readme/markdown/${packageName.value}`
153-
const version = requestedVersion.value
159+
const version = resolvedVersion.value
154160
return version ? `${base}/v/${version}` : base
155161
},
156162
{
@@ -200,7 +206,7 @@ const {
200206
} = useLazyFetch<InstallSizeResult | null>(
201207
() => {
202208
const base = `/api/registry/install-size/${packageName.value}`
203-
const version = requestedVersion.value
209+
const version = resolvedVersion.value
204210
return version ? `${base}/v/${version}` : base
205211
},
206212
{
@@ -213,7 +219,7 @@ onMounted(() => fetchInstallSize())
213219
const { data: skillsData } = useLazyFetch<SkillsListResponse>(
214220
() => {
215221
const base = `/skills/${packageName.value}`
216-
const version = requestedVersion.value
222+
const version = resolvedVersion.value
217223
return version ? `${base}/v/${version}` : base
218224
},
219225
{ default: () => ({ package: '', version: '', skills: [] }) },
@@ -222,11 +228,6 @@ const { data: skillsData } = useLazyFetch<SkillsListResponse>(
222228
const { data: packageAnalysis } = usePackageAnalysis(packageName, requestedVersion)
223229
const { data: moduleReplacement } = useModuleReplacement(packageName)
224230
225-
const { data: resolvedVersion, status: resolvedStatus } = await useResolvedVersion(
226-
packageName,
227-
requestedVersion,
228-
)
229-
230231
if (
231232
import.meta.server &&
232233
!resolvedVersion.value &&
@@ -503,6 +504,8 @@ const repoProviderIcon = computed((): IconClass => {
503504
return PROVIDER_ICONS[provider] ?? 'i-lucide:code'
504505
})
505506
507+
const viewOnGitProvider = useViewOnGitProvider(() => repoRef.value?.provider)
508+
506509
const homepageUrl = computed(() => {
507510
const homepage = displayVersion.value?.homepage
508511
if (!homepage) return null
@@ -863,7 +866,6 @@ const showSkeleton = shallowRef(false)
863866
:to="docsLink"
864867
aria-keyshortcuts="d"
865868
classicon="i-lucide:file-text"
866-
:title="$t('package.links.docs')"
867869
>
868870
<span class="max-sm:sr-only">{{ $t('package.links.docs') }}</span>
869871
</LinkBase>
@@ -873,7 +875,6 @@ const showSkeleton = shallowRef(false)
873875
:to="codeLink"
874876
aria-keyshortcuts="."
875877
classicon="i-lucide:code"
876-
:title="$t('package.links.code')"
877878
>
878879
<span class="max-sm:sr-only">{{ $t('package.links.code') }}</span>
879880
</LinkBase>
@@ -882,7 +883,6 @@ const showSkeleton = shallowRef(false)
882883
:to="{ name: 'compare', query: { packages: pkg.name } }"
883884
aria-keyshortcuts="c"
884885
classicon="i-lucide:git-compare"
885-
:title="$t('package.links.compare')"
886886
>
887887
<span class="max-sm:sr-only">{{ $t('package.links.compare') }}</span>
888888
</LinkBase>
@@ -900,7 +900,6 @@ const showSkeleton = shallowRef(false)
900900
<ButtonBase
901901
v-if="showScrollToTop"
902902
variant="secondary"
903-
:title="$t('common.scroll_to_top')"
904903
:aria-label="$t('common.scroll_to_top')"
905904
@click="scrollToTop"
906905
classicon="i-lucide:arrow-up"
@@ -1007,7 +1006,7 @@ const showSkeleton = shallowRef(false)
10071006
<li>
10081007
<LinkBase
10091008
:to="`https://www.npmjs.com/package/${pkg.name}`"
1010-
:title="$t('common.view_on_npm')"
1009+
:title="$t('common.view_on.npm')"
10111010
classicon="i-simple-icons:npm"
10121011
>
10131012
npm
@@ -1369,7 +1368,7 @@ const showSkeleton = shallowRef(false)
13691368
</div>
13701369
<TerminalInstall
13711370
:package-name="pkg.name"
1372-
:requested-version="requestedVersion ? resolvedVersion : requestedVersion"
1371+
:requested-version="resolvedVersion"
13731372
:install-version-override="installVersionOverride"
13741373
:jsr-info="jsrInfo"
13751374
:dev-dependency-suggestion="packageAnalysis?.devDependencySuggestion"
@@ -1452,7 +1451,8 @@ const showSkeleton = shallowRef(false)
14521451
target="_blank"
14531452
rel="noopener noreferrer"
14541453
class="link text-fg underline underline-offset-4 decoration-fg-subtle hover:(decoration-fg text-fg) transition-colors duration-200"
1455-
>{{ $t('package.readme.view_on_github') }}</a
1454+
>
1455+
{{ viewOnGitProvider }}</a
14561456
>
14571457
</p>
14581458

app/pages/~[username]/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ defineOgImageComponent('Default', {
156156
target="_blank"
157157
rel="noopener noreferrer"
158158
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
159-
:title="$t('common.view_on_npm')"
159+
:title="$t('common.view_on.npm')"
160160
>
161161
<span class="i-simple-icons:npm w-4 h-4" aria-hidden="true" />
162162
npm

docs/content/2.guide/1.features.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ You can further customize your badges by appending query parameters to the badge
159159

160160
##### `labelColor`
161161

162-
Overrides the default label color. You can pass a standard hex code (with or without the `#` prefix).
162+
Overrides the default label color. You can pass a standard hex code (with or without the `#` prefix). The label text color is automatically chosen (black or white) based on WCAG contrast ratio, so the badge remains readable.
163163

164164
- **Default**: `#0a0a0a`
165165
- **Usage**: `?labelColor=HEX_CODE`
@@ -173,16 +173,16 @@ Overrides the default label text. You can pass any string to customize the label
173173

174174
##### `color`
175175

176-
Overrides the default strategy color. You can pass a standard hex code (with or without the `#` prefix).
176+
Overrides the default strategy color. You can pass a standard hex code (with or without the `#` prefix). The text color is automatically chosen (black or white) based on WCAG contrast ratio, so the badge remains readable.
177177

178178
- **Default**: Depends on the badge type (e.g., version is blue, downloads are orange).
179179
- **Usage**: `?color=HEX_CODE`
180180

181-
| Example | URL |
182-
| :------------- | :------------------------------------- |
183-
| **Hot Pink** | `.../badge/version/nuxt?colorB=ff69b4` |
184-
| **Pure Black** | `.../badge/version/nuxt?colorB=000000` |
185-
| **Brand Blue** | `.../badge/version/nuxt?colorB=3b82f6` |
181+
| Example | URL |
182+
| :------------- | :------------------------------------ |
183+
| **Hot Pink** | `.../badge/version/nuxt?color=ff69b4` |
184+
| **Pure Black** | `.../badge/version/nuxt?color=000000` |
185+
| **Brand Blue** | `.../badge/version/nuxt?color=3b82f6` |
186186

187187
##### `name`
188188

i18n/locales/ar.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,18 @@
132132
"skip_link": "تخطي إلى المحتوى الرئيسي",
133133
"warnings": "تحذيرات:",
134134
"go_back_home": "العودة إلى الصفحة الرئيسية",
135-
"view_on_npm": "عرض على npm",
136135
"per_week": "/ أسبوع",
137136
"vanity_downloads_hint": "رقم زخرفي: لا توجد حزم معروضة | رقم زخرفي: للحزمة المعروضة | رقم زخرفي: للحزمتين المعروضتين | رقم زخرفي: مجموع {count} من الحزم المعروضة | رقم زخرفي: مجموع {count} من الحزم المعروضة | رقم زخرفي: مجموع {count} من الحزم المعروضة",
138137
"sort": {
139138
"name": "الاسم",
140139
"role": "الدور",
141140
"members": "الأعضاء"
142141
},
143-
"scroll_to_top": "التمرير إلى الأعلى"
142+
"scroll_to_top": "التمرير إلى الأعلى",
143+
"view_on": {
144+
"npm": "عرض على npm",
145+
"github": "عرض على GitHub"
146+
}
144147
},
145148
"package": {
146149
"not_found": "لم يتم العثور على الحزمة",
@@ -238,7 +241,6 @@
238241
"readme": {
239242
"title": "README (إقرأني)",
240243
"no_readme": "لا يتوفر README.",
241-
"view_on_github": "عرض على GitHub",
242244
"toc_title": "جدول المحتويات",
243245
"callout": {
244246
"note": "ملاحظة",

i18n/locales/az-AZ.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,18 @@
177177
"skip_link": "Əsas məzmuna keç",
178178
"warnings": "Xəbərdarlıqlar:",
179179
"go_back_home": "Ana səhifəyə qayıt",
180-
"view_on_npm": "npm-də bax",
181180
"per_week": "/ həftə",
182181
"vanity_downloads_hint": "Göstərici: paket göstərilmir | Göstərici: göstərilən paket üçün | Göstərici: {count} göstərilən paketin cəmi",
183182
"sort": {
184183
"name": "ad",
185184
"role": "rol",
186185
"members": "üzvlər"
187186
},
188-
"scroll_to_top": "Yuxarı qayıt"
187+
"scroll_to_top": "Yuxarı qayıt",
188+
"view_on": {
189+
"npm": "npm-də bax",
190+
"github": "GitHub-da bax"
191+
}
189192
},
190193
"package": {
191194
"not_found": "Paket Tapılmadı",
@@ -290,7 +293,6 @@
290293
"readme": {
291294
"title": "Readme",
292295
"no_readme": "README mövcud deyil.",
293-
"view_on_github": "GitHub-da bax",
294296
"toc_title": "Məzmun",
295297
"callout": {
296298
"note": "Qeyd",

0 commit comments

Comments
 (0)