Skip to content

Commit b762ce8

Browse files
committed
feat: highlight other version groups
1 parent 7715322 commit b762ce8

File tree

1 file changed

+55
-5
lines changed

1 file changed

+55
-5
lines changed

app/components/Package/Versions.vue

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,35 @@ function rowContainsCurrentVersion(row: (typeof visibleTagRows.value)[0]): boole
333333
const claimingTag = findClaimingTag(effectiveCurrentVersion.value)
334334
return claimingTag === row.tag
335335
}
336+
337+
function otherVersionsContainsCurrent(): boolean {
338+
if (!effectiveCurrentVersion.value) return false
339+
340+
const claimingTag = findClaimingTag(effectiveCurrentVersion.value)
341+
342+
// If a tag claims it, check if that tag is in visibleTagRows
343+
if (claimingTag) {
344+
const isInVisibleTags = visibleTagRows.value.some(row => row.tag === claimingTag)
345+
if (!isInVisibleTags) return true
346+
return false
347+
}
348+
349+
// No tag claims it - it would be in otherMajorGroups
350+
return true
351+
}
352+
353+
function hiddenRowContainsCurrent(row: (typeof hiddenTagRows.value)[0]): boolean {
354+
if (!effectiveCurrentVersion.value) return false
355+
if (row.primaryVersion.version === effectiveCurrentVersion.value) return true
356+
357+
const claimingTag = findClaimingTag(effectiveCurrentVersion.value)
358+
return claimingTag === row.tag
359+
}
360+
361+
function majorGroupContainsCurrent(group: (typeof otherMajorGroups.value)[0]): boolean {
362+
if (!effectiveCurrentVersion.value) return false
363+
return group.versions.some(v => v.version === effectiveCurrentVersion.value)
364+
}
336365
</script>
337366

338367
<template>
@@ -520,7 +549,8 @@ function rowContainsCurrentVersion(row: (typeof visibleTagRows.value)[0]): boole
520549
<div class="p-1">
521550
<button
522551
type="button"
523-
class="flex items-center gap-2 text-start rounded-sm"
552+
class="flex items-center gap-2 text-start rounded-sm w-full"
553+
:class="otherVersionsContainsCurrent() ? 'bg-bg-subtle' : ''"
524554
:aria-expanded="otherVersionsExpanded"
525555
:aria-label="
526556
otherVersionsExpanded
@@ -562,7 +592,12 @@ function rowContainsCurrentVersion(row: (typeof visibleTagRows.value)[0]): boole
562592
<!-- Expanded other versions -->
563593
<div v-if="otherVersionsExpanded" class="ms-4 ps-2 border-is border-border space-y-0.5">
564594
<!-- Hidden tag rows (overflow from visible tags) -->
565-
<div v-for="row in hiddenTagRows" :key="row.id" class="py-1">
595+
<div
596+
v-for="row in hiddenTagRows"
597+
:key="row.id"
598+
class="py-1"
599+
:class="hiddenRowContainsCurrent(row) ? 'rounded bg-bg-subtle px-2 -mx-2' : ''"
600+
>
566601
<div class="flex items-center justify-between gap-2">
567602
<NuxtLink
568603
:to="versionRoute(row.primaryVersion.version)"
@@ -614,7 +649,11 @@ function rowContainsCurrentVersion(row: (typeof visibleTagRows.value)[0]): boole
614649
<template v-if="otherMajorGroups.length > 0">
615650
<div v-for="group in otherMajorGroups" :key="group.groupKey">
616651
<!-- Version group header -->
617-
<div v-if="group.versions.length > 1" class="py-1">
652+
<div
653+
v-if="group.versions.length > 1"
654+
class="py-1"
655+
:class="majorGroupContainsCurrent(group) ? 'rounded bg-bg-subtle px-2 -mx-2' : ''"
656+
>
618657
<div class="flex items-center justify-between gap-2">
619658
<div class="flex items-center gap-2 min-w-0">
620659
<button
@@ -696,7 +735,11 @@ function rowContainsCurrentVersion(row: (typeof visibleTagRows.value)[0]): boole
696735
</div>
697736
</div>
698737
<!-- Single version (no expand needed) -->
699-
<div v-else class="py-1">
738+
<div
739+
v-else
740+
class="py-1"
741+
:class="majorGroupContainsCurrent(group) ? 'rounded bg-bg-subtle px-2 -mx-2' : ''"
742+
>
700743
<div class="flex items-center justify-between gap-2">
701744
<div class="flex items-center gap-2 min-w-0">
702745
<span class="w-4 shrink-0" />
@@ -758,7 +801,14 @@ function rowContainsCurrentVersion(row: (typeof visibleTagRows.value)[0]): boole
758801
v-if="expandedMajorGroups.has(group.groupKey) && group.versions.length > 1"
759802
class="ms-6 space-y-0.5"
760803
>
761-
<div v-for="v in group.versions.slice(1)" :key="v.version" class="py-1">
804+
<div
805+
v-for="v in group.versions.slice(1)"
806+
:key="v.version"
807+
class="py-1"
808+
:class="
809+
v.version === effectiveCurrentVersion ? 'rounded bg-bg-subtle px-2 -mx-2' : ''
810+
"
811+
>
762812
<div class="flex items-center justify-between gap-2">
763813
<NuxtLink
764814
:to="versionRoute(v.version)"

0 commit comments

Comments
 (0)