feat: add sticky effect to the readme header on the readme page#1775
feat: add sticky effect to the readme header on the readme page#1775btea wants to merge 1 commit intonpmx-dev:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
📝 WalkthroughWalkthroughTwo package page files were modified. The primary change adds dual-readme header handling to the package details page component, introducing a separate readmeHeader reference and isReadmeHeaderPinned state. Scroll event logic was extended to compute and apply pin status for both main and readme headers. The README section template was updated to render a new readmeHeader element with sticky styling and dynamic styling based on pin state. Additionally, the page metadata scrollMargin value was adjusted from 150 to 200 pixels. Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
app/pages/package/[[org]]/[name].vue (1)
1401-1405: Avoid hard-coding the README sticky offset.Line 1403 uses
top-34, which can become fragile if the main sticky header height changes (for example, wrapping package names or translated content). Prefer deriving this offset from the actual header geometry to prevent overlap.♻️ Example refactor
- <div - ref="readmeHeader" - class="flex sticky top-34 z-10 flex-wrap items-center justify-between mb-3 py-1 -mx-1 px-2 rounded-md transition-shadow duration-200" - :class="{ 'bg-bg shadow-sm': isReadmeHeaderPinned }" - > + <div + ref="readmeHeader" + class="flex sticky z-10 flex-wrap items-center justify-between mb-3 py-1 -mx-1 px-2 rounded-md transition-shadow duration-200" + :style="{ top: readmeHeaderTop }" + :class="{ 'bg-bg shadow-sm': isReadmeHeaderPinned }" + >const readmeHeaderTop = computed(() => { const el = header.value if (!el) return '8.5rem' const top = parseFloat(getComputedStyle(el).top) || 0 const height = el.getBoundingClientRect().height return `${Math.ceil(top + height)}px` })
|
Do you mean to add space between the sticky header and the sticky part of the readme? |
|
I meant below, as you can see on the screenshot I posted before, the spacing between the readme menu button and the content is very thin |
|
In light mode the bottom border makes the separation clear, in dark mode it seems there is no border (checking on my phone so I might be wrong). Edit: |


🔗 Linked issue
Resolves #859
🧭 Context
When the README file contains a lot of content, scroll down to the next section. Anchor points should be available sticky for quick navigation to specific locations.
📚 Description
Jietu20260301-135912-HD.mp4