Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 40 additions & 4 deletions app/pages/package/[...package].vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,44 @@ onMounted(() => {
checkHeaderPosition()
})

const windowSize = useWindowSize()
const sidebar = useTemplateRef<HTMLDivElement>('sidebar')
const sidebarBounds = useElementBounding(sidebar)
const scrollState = useWindowScroll()
const scrollDirection = shallowRef<'up' | 'down'>('down')

const sidebarOverflow = computed(() => {
return sidebarBounds.height.value > windowSize.height.value - 120
})

const sidebarStyles = computed(() => {
if (!sidebarOverflow.value) {
return {
alignSelf: 'flex-start',
top: '80px',
}
}

if (scrollDirection.value === 'down') {
return {
alignSelf: 'flex-end',
bottom: '40px',
}
}

if (scrollDirection.value === 'up') {
return {
alignSelf: 'flex-start',
top: '80px',
}
}
})

watch(scrollState.directions, ({ bottom, top }) => {
if (bottom) scrollDirection.value = 'down'
if (top) scrollDirection.value = 'up'
})

const { packageName, requestedVersion, orgName } = usePackageRoute()
const selectedPM = useSelectedPackageManager()
const activePmId = computed(() => selectedPM.value ?? 'npm')
Expand Down Expand Up @@ -1165,11 +1203,9 @@ onKeyStroke(
</div>
</section>
</section>
<div class="area-sidebar">
<div class="area-sidebar flex">
<!-- Sidebar -->
<div
class="sidebar-scroll sticky top-34 space-y-6 sm:space-y-8 min-w-0 overflow-y-auto pr-2.5 hover:pr-0.5 lg:(max-h-[calc(100dvh-8.5rem)] overscroll-contain) xl:(top-22 pt-2 max-h-[calc(100dvh-6rem)])"
>
<div ref="sidebar" class="sticky w-full xl:(pt-2)" :style="sidebarStyles">
<!-- Maintainers (with admin actions when connected) -->
<PackageMaintainers :package-name="pkg.name" :maintainers="pkg.maintainers" />

Expand Down
Loading