Skip to content

Commit 83ae495

Browse files
committed
style: sync links and static tags
1 parent 585aa63 commit 83ae495

2 files changed

Lines changed: 18 additions & 34 deletions

File tree

app/components/Package/MetricsBadges.vue

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { NuxtLink } from '#components'
2+
import { ButtonLink, TagStatic } from '#components'
33
44
const props = defineProps<{
55
packageName: string
@@ -56,62 +56,42 @@ const typesHref = computed(() => {
5656
<!-- TypeScript types badge -->
5757
<li v-if="!props.isBinary">
5858
<TooltipApp :text="typesTooltip">
59-
<component
60-
:is="typesHref ? NuxtLink : 'span'"
61-
:to="typesHref"
62-
:tabindex="!typesHref ? 0 : undefined"
63-
class="inline-flex items-center gap-1 px-1.5 py-0.5 font-mono text-xs rounded transition-colors duration-200"
64-
:class="[
65-
hasTypes
66-
? 'text-fg-muted bg-bg-muted border border-border'
67-
: 'text-fg-subtle bg-bg-subtle border border-border-subtle',
68-
typesHref
69-
? 'hover:text-fg hover:border-border-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50'
70-
: '',
71-
]"
72-
>
59+
<ButtonLink v-if="typesHref" variant="tag" :to="typesHref">
60+
<span class="w-3 h-3 i-carbon-checkmark" aria-hidden="true" />
61+
{{ $t('package.metrics.types_label') }}
62+
</ButtonLink>
63+
<TagStatic v-else :variant="hasTypes ? 'default' : 'disabled'" :tabindex="0">
7364
<span
7465
class="w-3 h-3"
7566
:class="hasTypes ? 'i-carbon-checkmark' : 'i-carbon-close'"
7667
aria-hidden="true"
7768
/>
7869
{{ $t('package.metrics.types_label') }}
79-
</component>
70+
</TagStatic>
8071
</TooltipApp>
8172
</li>
8273

8374
<!-- ESM badge (show with X if missing) -->
8475
<li>
8576
<TooltipApp :text="hasEsm ? $t('package.metrics.esm') : $t('package.metrics.no_esm')">
86-
<span
87-
tabindex="0"
88-
class="inline-flex items-center gap-1 px-1.5 py-0.5 font-mono text-xs rounded transition-colors duration-200"
89-
:class="
90-
hasEsm
91-
? 'text-fg-muted bg-bg-muted border border-border'
92-
: 'text-fg-subtle bg-bg-subtle border border-border-subtle'
93-
"
94-
>
77+
<TagStatic tabindex="0" :variant="hasEsm ? 'default' : 'disabled'">
9578
<span
9679
class="w-3 h-3"
9780
:class="hasEsm ? 'i-carbon-checkmark' : 'i-carbon-close'"
9881
aria-hidden="true"
9982
/>
10083
ESM
101-
</span>
84+
</TagStatic>
10285
</TooltipApp>
10386
</li>
10487

10588
<!-- CJS badge (only show if present) -->
10689
<li v-if="hasCjs">
10790
<TooltipApp :text="$t('package.metrics.cjs')">
108-
<span
109-
tabindex="0"
110-
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"
111-
>
91+
<TagStatic tabindex="0">
11292
<span class="i-carbon-checkmark w-3 h-3" aria-hidden="true" />
11393
CJS
114-
</span>
94+
</TagStatic>
11595
</TooltipApp>
11696
</li>
11797
</ul>

app/components/Tag/Static.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<script setup lang="ts">
2-
const props = withDefaults(defineProps<{ as?: string | Component }>(), { as: 'span' })
2+
const props = withDefaults(
3+
defineProps<{ as?: string | Component; variant?: 'disabled' | 'default' }>(),
4+
{ as: 'span', variant: 'default' },
5+
)
36
</script>
47

58
<template>
69
<component
710
:is="as"
8-
class="inline-flex items-center px-2 py-0.5 text-xs font-mono text-fg-muted bg-bg-muted border border-border rounded"
11+
class="bg-bg-muted text-fg-muted inline-flex gap-x-1 items-center justify-center font-mono border border-transparent rounded-md text-xs px-2 py-0.5"
12+
:class="{ 'opacity-40': variant === 'disabled' }"
913
>
10-
<slot />
14+
<slot />!
1115
</component>
1216
</template>

0 commit comments

Comments
 (0)