@@ -7,11 +7,13 @@ const props = defineProps<{
77 version? : string
88}>()
99
10- const { data : analysis } = usePackageAnalysis (
10+ const { data : analysis, status } = usePackageAnalysis (
1111 () => props .packageName ,
1212 () => props .version ,
1313)
1414
15+ const isLoading = computed (() => status .value !== ' error' && ! analysis .value )
16+
1517// ESM support
1618const hasEsm = computed (() => {
1719 if (! analysis .value ) return false
@@ -52,25 +54,33 @@ const typesHref = computed(() => {
5254 </script >
5355
5456<template >
55- <ul v-if = " analysis " class =" flex items-center gap-1.5 list-none m-0 p-0" >
57+ <ul class =" flex items-center gap-1.5 list-none m-0 p-0" >
5658 <!-- TypeScript types badge -->
57- <li v-if =" !props.isBinary" >
59+ <li v-if =" !props.isBinary" class = " contents " >
5860 <TooltipApp :text =" typesTooltip" >
5961 <component
6062 :is =" typesHref ? NuxtLink : 'span'"
6163 :to =" typesHref"
6264 :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 focus-visible:(outline-2 outline-accent)"
65+ class =" flex items-center gap-1 px-1.5 py-0.5 font-mono text-xs rounded transition-colors duration-200 focus-visible:(outline-2 outline-accent)"
6466 :class =" [
65- hasTypes
66- ? 'text-fg-muted bg-bg-muted border border-border'
67- : 'text-fg-subtle bg-bg-subtle border border-border-subtle',
67+ isLoading
68+ ? 'text-fg-subtle bg-bg-subtle border border-border-subtle'
69+ : hasTypes
70+ ? 'text-fg-muted bg-bg-muted border border-border'
71+ : 'text-fg-subtle bg-bg-subtle border border-border-subtle',
6872 typesHref
6973 ? 'hover:text-fg hover:border-border-hover focus-visible:outline-accent/70'
7074 : '',
7175 ]"
7276 >
7377 <span
78+ v-if =" isLoading"
79+ class =" i-carbon-circle-dash w-3 h-3 motion-safe:animate-spin"
80+ aria-hidden =" true"
81+ />
82+ <span
83+ v-else
7484 class =" w-3 h-3"
7585 :class =" hasTypes ? 'i-carbon-checkmark' : 'i-carbon-close'"
7686 aria-hidden =" true"
@@ -81,18 +91,28 @@ const typesHref = computed(() => {
8191 </li >
8292
8393 <!-- ESM badge (show with X if missing) -->
84- <li >
85- <TooltipApp :text =" hasEsm ? $t('package.metrics.esm') : $t('package.metrics.no_esm')" >
94+ <li class =" contents" >
95+ <TooltipApp
96+ :text =" isLoading ? '' : hasEsm ? $t('package.metrics.esm') : $t('package.metrics.no_esm')"
97+ >
8698 <span
8799 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 focus-visible:(outline-2 outline-accent)"
100+ class =" flex items-center gap-1 px-1.5 py-0.5 font-mono text-xs rounded transition-colors duration-200 focus-visible:(outline-2 outline-accent)"
89101 :class ="
90- hasEsm
91- ? 'text-fg-muted bg-bg-muted border border-border'
92- : 'text-fg-subtle bg-bg-subtle border border-border-subtle'
102+ isLoading
103+ ? 'text-fg-subtle bg-bg-subtle border border-border-subtle'
104+ : hasEsm
105+ ? 'text-fg-muted bg-bg-muted border border-border'
106+ : 'text-fg-subtle bg-bg-subtle border border-border-subtle'
93107 "
94108 >
95109 <span
110+ v-if =" isLoading"
111+ class =" i-carbon-circle-dash w-3 h-3 motion-safe:animate-spin"
112+ aria-hidden =" true"
113+ />
114+ <span
115+ v-else
96116 class =" w-3 h-3"
97117 :class =" hasEsm ? 'i-carbon-checkmark' : 'i-carbon-close'"
98118 aria-hidden =" true"
@@ -102,14 +122,24 @@ const typesHref = computed(() => {
102122 </TooltipApp >
103123 </li >
104124
105- <!-- CJS badge (only show if present) -->
106- <li v-if =" hasCjs" >
107- <TooltipApp :text =" $t('package.metrics.cjs')" >
125+ <!-- CJS badge -->
126+ <li v-if =" isLoading || hasCjs" class = " contents " >
127+ <TooltipApp :text =" isLoading ? '' : $t('package.metrics.cjs')" >
108128 <span
109129 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 focus-visible:(outline-2 outline-accent)"
130+ class =" flex items-center gap-1 px-1.5 py-0.5 font-mono text-xs rounded transition-colors duration-200 focus-visible:(outline-2 outline-accent)"
131+ :class ="
132+ isLoading
133+ ? 'text-fg-subtle bg-bg-subtle border border-border-subtle'
134+ : 'text-fg-muted bg-bg-muted border border-border'
135+ "
111136 >
112- <span class =" i-carbon-checkmark w-3 h-3" aria-hidden =" true" />
137+ <span
138+ v-if =" isLoading"
139+ class =" i-carbon-circle-dash w-3 h-3 motion-safe:animate-spin"
140+ aria-hidden =" true"
141+ />
142+ <span v-else class =" i-carbon-checkmark w-3 h-3" aria-hidden =" true" />
113143 CJS
114144 </span >
115145 </TooltipApp >
0 commit comments