Skip to content

Commit 368e2d0

Browse files
gusa4grrdanielroe
andauthored
fix: hide types badge for binary-only packages (#597)
Co-authored-by: Yevhen Husak <gusa4grr@users.noreply.github.com> Co-authored-by: Daniel Roe <daniel@roe.dev>
1 parent 4fe042d commit 368e2d0

3 files changed

Lines changed: 51 additions & 48 deletions

File tree

app/components/PackageMetricsBadges.vue

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { NuxtLink } from '#components'
33
44
const props = defineProps<{
55
packageName: string
6+
isBinary?: boolean
67
version?: string
78
}>()
89
@@ -43,7 +44,7 @@ const typesTooltip = computed(() => {
4344
4445
const typesHref = computed(() => {
4546
if (!analysis.value) return null
46-
if (analysis.value.types.kind === '@types') {
47+
if (analysis.value.types?.kind === '@types') {
4748
return `/${analysis.value.types.packageName}`
4849
}
4950
return null
@@ -53,59 +54,62 @@ const typesHref = computed(() => {
5354
<template>
5455
<ul v-if="analysis" class="flex items-center gap-1.5 list-none m-0 p-0">
5556
<!-- TypeScript types badge -->
56-
<li>
57-
<component
58-
:is="typesHref ? NuxtLink : 'span'"
59-
:to="typesHref"
60-
class="inline-flex items-center gap-1 px-1.5 py-0.5 font-mono text-xs rounded transition-colors duration-200"
61-
:class="[
62-
hasTypes
63-
? 'text-fg-muted bg-bg-muted border border-border'
64-
: 'text-fg-subtle bg-bg-subtle border border-border-subtle',
65-
typesHref
66-
? 'hover:text-fg hover:border-border-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50'
67-
: '',
68-
]"
69-
:title="typesTooltip"
70-
>
71-
<span
72-
class="w-3 h-3"
73-
:class="hasTypes ? 'i-carbon-checkmark' : 'i-carbon-close'"
74-
aria-hidden="true"
75-
/>
76-
{{ $t('package.metrics.types_label') }}
77-
</component>
57+
<li v-if="!props.isBinary">
58+
<AppTooltip :text="typesTooltip">
59+
<component
60+
:is="typesHref ? NuxtLink : 'span'"
61+
:to="typesHref"
62+
class="inline-flex items-center gap-1 px-1.5 py-0.5 font-mono text-xs rounded transition-colors duration-200"
63+
:class="[
64+
hasTypes
65+
? 'text-fg-muted bg-bg-muted border border-border'
66+
: 'text-fg-subtle bg-bg-subtle border border-border-subtle',
67+
typesHref
68+
? 'hover:text-fg hover:border-border-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50'
69+
: '',
70+
]"
71+
>
72+
<span
73+
class="w-3 h-3"
74+
:class="hasTypes ? 'i-carbon-checkmark' : 'i-carbon-close'"
75+
aria-hidden="true"
76+
/>
77+
{{ $t('package.metrics.types_label') }}
78+
</component>
79+
</AppTooltip>
7880
</li>
7981

8082
<!-- ESM badge (show with X if missing) -->
8183
<li>
82-
<span
83-
class="inline-flex items-center gap-1 px-1.5 py-0.5 font-mono text-xs rounded transition-colors duration-200"
84-
:class="
85-
hasEsm
86-
? 'text-fg-muted bg-bg-muted border border-border'
87-
: 'text-fg-subtle bg-bg-subtle border border-border-subtle'
88-
"
89-
:title="hasEsm ? $t('package.metrics.esm') : $t('package.metrics.no_esm')"
90-
>
84+
<AppTooltip :text="hasEsm ? $t('package.metrics.esm') : $t('package.metrics.no_esm')">
9185
<span
92-
class="w-3 h-3"
93-
:class="hasEsm ? 'i-carbon-checkmark' : 'i-carbon-close'"
94-
aria-hidden="true"
95-
/>
96-
ESM
97-
</span>
86+
class="inline-flex items-center gap-1 px-1.5 py-0.5 font-mono text-xs rounded transition-colors duration-200"
87+
:class="
88+
hasEsm
89+
? 'text-fg-muted bg-bg-muted border border-border'
90+
: 'text-fg-subtle bg-bg-subtle border border-border-subtle'
91+
"
92+
>
93+
<span
94+
class="w-3 h-3"
95+
:class="hasEsm ? 'i-carbon-checkmark' : 'i-carbon-close'"
96+
aria-hidden="true"
97+
/>
98+
ESM
99+
</span>
100+
</AppTooltip>
98101
</li>
99102

100103
<!-- CJS badge (only show if present) -->
101104
<li v-if="hasCjs">
102-
<span
103-
class="inline-flex items-center gap-1 px-1.5 py-0.5 font-mono text-xs text-fg-muted bg-bg-muted border border-border rounded transition-colors duration-200"
104-
:title="$t('package.metrics.cjs')"
105-
>
106-
<span class="i-carbon-checkmark w-3 h-3" aria-hidden="true" />
107-
CJS
108-
</span>
105+
<AppTooltip :text="$t('package.metrics.cjs')">
106+
<span
107+
class="inline-flex items-center gap-1 px-1.5 py-0.5 font-mono text-xs text-fg-muted bg-bg-muted border border-border rounded transition-colors duration-200"
108+
>
109+
<span class="i-carbon-checkmark w-3 h-3" aria-hidden="true" />
110+
CJS
111+
</span>
112+
</AppTooltip>
109113
</li>
110114
</ul>
111115
</template>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ function handleClick(event: MouseEvent) {
462462
v-if="displayVersion"
463463
:package-name="pkg.name"
464464
:version="displayVersion.version"
465+
:is-binary="isBinaryOnly"
465466
class="self-baseline ms-1 sm:ms-2"
466467
/>
467468
<template #fallback>

app/utils/run-command.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ export interface PackageMetadata {
2323
* - Has bin field but no main, module, or exports fields
2424
*/
2525
export function isBinaryOnlyPackage(pkg: PackageMetadata): boolean {
26-
const baseName = pkg.name.startsWith('@') ? pkg.name.split('/')[1] : pkg.name
27-
2826
// Check create-* patterns
29-
if (baseName?.startsWith('create-') || pkg.name.includes('/create-')) {
27+
if (isCreatePackage(pkg.name)) {
3028
return true
3129
}
3230

0 commit comments

Comments
 (0)