Skip to content

Commit 1bfa878

Browse files
committed
refactor: use design components for package sidebar
1 parent 7b860d1 commit 1bfa878

6 files changed

Lines changed: 83 additions & 136 deletions

File tree

app/components/Link/Base.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const props = withDefaults(
5959
v-else
6060
class="group inline-flex gap-x-1 items-center justify-center"
6161
:class="{
62-
'text-fg underline-offset-4 underline decoration-1 decoration-fg/50 hover:(no-underline text-fg/80) transition-colors duration-200':
62+
'text-fg underline-offset-[0.2rem] underline decoration-1 decoration-fg/50 hover:(no-underline text-fg/80) transition-colors duration-200':
6363
variant === 'link',
6464
'gap-x-1 font-mono border border-border rounded-md transition-all duration-200 aria-current:(bg-fg text-bg border-fg hover:enabled:(text-bg/50))':
6565
variant !== 'link',

app/components/Package/Dependencies.vue

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,9 @@ const sortedOptionalDependencies = computed(() => {
8181
:key="dep"
8282
class="flex items-center justify-between py-1 text-sm gap-2"
8383
>
84-
<NuxtLink
85-
:to="{ name: 'package', params: { package: dep.split('/') } }"
86-
class="font-mono text-fg-muted hover:text-fg transition-colors duration-200 truncate min-w-0 flex-1"
87-
>
84+
<LinkBase :to="{ name: 'package', params: { package: dep.split('/') } }">
8885
{{ dep }}
89-
</NuxtLink>
86+
</LinkBase>
9087
<span class="flex items-center gap-1 max-w-[40%]">
9188
<span
9289
v-if="outdatedDeps[dep]"
@@ -97,7 +94,7 @@ const sortedOptionalDependencies = computed(() => {
9794
>
9895
<span class="i-carbon:warning-alt w-3 h-3" />
9996
</span>
100-
<NuxtLink
97+
<LinkBase
10198
v-if="getVulnerableDepInfo(dep)"
10299
:to="{
103100
name: 'package',
@@ -106,33 +103,33 @@ const sortedOptionalDependencies = computed(() => {
106103
class="shrink-0"
107104
:class="SEVERITY_TEXT_COLORS[getHighestSeverity(getVulnerableDepInfo(dep)!.counts)]"
108105
:title="`${getVulnerableDepInfo(dep)!.counts.total} vulnerabilities`"
106+
iconclass="i-carbon:security"
109107
>
110-
<span class="i-carbon:security w-3 h-3" aria-hidden="true" />
111108
<span class="sr-only">{{ $t('package.dependencies.view_vulnerabilities') }}</span>
112-
</NuxtLink>
113-
<NuxtLink
109+
</LinkBase>
110+
<LinkBase
114111
v-if="getDeprecatedDepInfo(dep)"
115112
:to="{
116113
name: 'package',
117114
params: { package: [...dep.split('/'), 'v', getDeprecatedDepInfo(dep)!.version] },
118115
}"
119116
class="shrink-0 text-purple-500"
120117
:title="getDeprecatedDepInfo(dep)!.message"
118+
iconclass="i-carbon:warning-hex"
121119
>
122-
<span class="i-carbon-warning-hex w-3 h-3" aria-hidden="true" />
123120
<span class="sr-only">{{ $t('package.deprecated.label') }}</span>
124-
</NuxtLink>
125-
<NuxtLink
121+
</LinkBase>
122+
<LinkBase
126123
:to="{
127124
name: 'package',
128125
params: { package: [...dep.split('/'), 'v', version] },
129126
}"
130-
class="font-mono text-xs text-end truncate"
127+
class="truncate"
131128
:class="getVersionClass(outdatedDeps[dep])"
132129
:title="outdatedDeps[dep] ? getOutdatedTooltip(outdatedDeps[dep], $t) : version"
133130
>
134131
{{ version }}
135-
</NuxtLink>
132+
</LinkBase>
136133
<span v-if="outdatedDeps[dep]" class="sr-only">
137134
({{ getOutdatedTooltip(outdatedDeps[dep], $t) }})
138135
</span>
@@ -173,33 +170,29 @@ const sortedOptionalDependencies = computed(() => {
173170
class="flex items-center justify-between py-1 text-sm gap-1 min-w-0"
174171
>
175172
<div class="flex items-center gap-1 min-w-0 flex-1">
176-
<NuxtLink
173+
<LinkBase
177174
:to="{
178175
name: 'package',
179176
params: { package: peer.name.split('/') },
180177
}"
181-
class="font-mono text-fg-muted hover:text-fg transition-colors duration-200 truncate"
178+
class="truncate"
182179
>
183180
{{ peer.name }}
184-
</NuxtLink>
185-
<span
186-
v-if="peer.optional"
187-
class="px-1 py-0.5 font-mono text-[10px] text-fg-subtle bg-bg-muted border border-border rounded shrink-0"
188-
:title="$t('package.dependencies.optional')"
189-
>
181+
</LinkBase>
182+
<TagStatic v-if="peer.optional" :title="$t('package.dependencies.optional')">
190183
{{ $t('package.dependencies.optional') }}
191-
</span>
184+
</TagStatic>
192185
</div>
193-
<NuxtLink
186+
<LinkBase
194187
:to="{
195188
name: 'package',
196189
params: { package: [...peer.name.split('/'), 'v', peer.version] },
197190
}"
198-
class="font-mono text-xs text-fg-subtle max-w-[40%] truncate"
191+
class="truncate"
199192
:title="peer.version"
200193
>
201194
{{ peer.version }}
202-
</NuxtLink>
195+
</LinkBase>
203196
</li>
204197
</ul>
205198
<button
@@ -238,28 +231,25 @@ const sortedOptionalDependencies = computed(() => {
238231
:key="dep"
239232
class="flex items-center justify-between py-1 text-sm gap-2"
240233
>
241-
<NuxtLink
242-
:to="{ name: 'package', params: { package: dep.split('/') } }"
243-
class="font-mono text-fg-muted hover:text-fg transition-colors duration-200 truncate min-w-0 flex-1"
244-
>
234+
<LinkBase :to="{ name: 'package', params: { package: dep.split('/') } }" class="truncate">
245235
{{ dep }}
246-
</NuxtLink>
247-
<NuxtLink
236+
</LinkBase>
237+
<LinkBase
248238
:to="{
249239
name: 'package',
250240
params: { package: [...dep.split('/'), 'v', version] },
251241
}"
252-
class="font-mono text-xs text-fg-subtle max-w-[40%] text-end truncate"
242+
class="truncate"
253243
:title="version"
254244
>
255245
{{ version }}
256-
</NuxtLink>
246+
</LinkBase>
257247
</li>
258248
</ul>
259249
<button
260250
v-if="sortedOptionalDependencies.length > 10 && !optionalDepsExpanded"
261251
type="button"
262-
class="mt-2 font-mono text-xs text-fg-muted hover:text-fg transition-colors duration-200 rounded focus-visible:outline-accent/70"
252+
class="mt-2 truncate"
263253
@click="optionalDepsExpanded = true"
264254
>
265255
{{

app/components/Package/InstallScripts.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ const isExpanded = shallowRef(false)
7272
:key="dep"
7373
class="flex items-center justify-between py-0.5 text-sm gap-2"
7474
>
75-
<NuxtLink
75+
<LinkBase
7676
:to="{ name: 'package', params: { package: dep.split('/') } }"
7777
class="font-mono text-fg-muted hover:text-fg transition-colors duration-200 truncate min-w-0"
7878
>
7979
{{ dep }}
80-
</NuxtLink>
80+
</LinkBase>
8181
<span class="flex items-center gap-1">
8282
<span
8383
v-if="

app/components/Package/Maintainers.vue

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ watch(
183183
class="flex items-center justify-between gap-2"
184184
>
185185
<div class="flex items-center gap-2 min-w-0">
186-
<NuxtLink
186+
<LinkBase
187187
v-if="maintainer.name"
188188
:to="{
189189
name: '~username',
@@ -192,7 +192,7 @@ watch(
192192
class="link-subtle font-mono text-sm shrink-0"
193193
>
194194
~{{ maintainer.name }}
195-
</NuxtLink>
195+
</LinkBase>
196196
<span v-else class="font-mono text-sm text-fg-muted">{{ maintainer.email }}</span>
197197

198198
<!-- Access source badges -->
@@ -214,10 +214,10 @@ watch(
214214
</div>
215215

216216
<!-- Remove button (only when can manage and not self) -->
217-
<button
217+
<ButtonBase
218218
v-if="canManageOwners && maintainer.name && maintainer.name !== npmUser"
219219
type="button"
220-
class="p-1 text-fg-subtle hover:text-red-400 transition-colors duration-200 shrink-0 rounded focus-visible:outline-accent/70"
220+
class="hover:text-red-400"
221221
:aria-label="
222222
$t('package.maintainers.remove_owner', {
223223
name: maintainer.name,
@@ -226,15 +226,13 @@ watch(
226226
@click="handleRemoveOwner(maintainer.name)"
227227
>
228228
<span class="i-carbon-close w-3.5 h-3.5" aria-hidden="true" />
229-
</button>
229+
</ButtonBase>
230230
</li>
231231
</ul>
232232

233233
<!-- Show more/less toggle (only when not managing and there are hidden maintainers) -->
234-
<button
234+
<ButtonBase
235235
v-if="!canManageOwners && hiddenMaintainersCount > 0"
236-
type="button"
237-
class="mt-2 text-xs text-fg-muted hover:text-fg transition-colors duration-200 focus-visible:outline-accent/70 rounded"
238236
@click="showAllMaintainers = !showAllMaintainers"
239237
>
240238
{{
@@ -244,7 +242,7 @@ watch(
244242
count: hiddenMaintainersCount,
245243
})
246244
}}
247-
</button>
245+
</ButtonBase>
248246

249247
<!-- Add owner form (only when can manage) -->
250248
<div v-if="canManageOwners" class="mt-3">
@@ -262,31 +260,24 @@ watch(
262260
v-bind="noCorrect"
263261
class="flex-1 px-2 py-1 font-mono text-sm bg-bg-subtle border border-border rounded text-fg placeholder:text-fg-subtle transition-colors duration-200 focus:border-border-hover focus-visible:outline-accent/70"
264262
/>
265-
<button
266-
type="submit"
267-
:disabled="!newOwnerUsername.trim() || isAdding"
268-
class="px-2 py-1 font-mono text-xs text-bg bg-fg rounded transition-all duration-200 hover:bg-fg/90 disabled:opacity-50 disabled:cursor-not-allowed focus-visible:outline-accent/70"
269-
>
263+
<ButtonBase type="submit" :disabled="!newOwnerUsername.trim() || isAdding">
270264
{{ isAdding ? '…' : $t('package.maintainers.add_button') }}
271-
</button>
272-
<button
273-
type="button"
274-
class="p-1 text-fg-subtle hover:text-fg transition-colors duration-200 rounded focus-visible:outline-accent/70"
265+
</ButtonBase>
266+
<ButtonBase
275267
:aria-label="$t('package.maintainers.cancel_add')"
276268
@click="showAddOwner = false"
277-
>
278-
<span class="i-carbon-close w-4 h-4" aria-hidden="true" />
279-
</button>
269+
iconclass="i-carbon-close"
270+
/>
280271
</form>
281272
</div>
282-
<button
273+
<ButtonBase
283274
v-else
284275
type="button"
285276
class="w-full px-3 py-1.5 font-mono text-xs text-fg-muted bg-bg-subtle border border-border rounded transition-colors duration-200 hover:text-fg hover:border-border-hover focus-visible:outline-accent/70"
286277
@click="showAddOwner = true"
287278
>
288279
{{ $t('package.maintainers.add_owner') }}
289-
</button>
280+
</ButtonBase>
290281
</div>
291282
</CollapsibleSection>
292283
</template>

0 commit comments

Comments
 (0)