fix: wrap code viewer lines by computing width#2070
fix: wrap code viewer lines by computing width#2070nosthrillz wants to merge 4 commits intonpmx-dev:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
📝 WalkthroughWalkthroughThis pull request updates the code viewer and package-code page presentation without changing behaviour or public signatures. The Code Viewer moves style application to the root, exposes a --line-digits CSS variable, computes --line-numbers-width, and converts the layout to a flex-based structure that lets code lines wrap while allowing highlighted lines to span full width. The package-code page receives a .main-content wrapper and responsive sidebar (.file-tree) and viewer (.file-viewer) width rules to manage column sizing. 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)
📝 Coding Plan
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 Tip You can validate your CodeRabbit configuration file in your editor.If your editor has YAML language server, you can enable auto-completion and validation by adding |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: db7d3812-0584-449a-ac8f-5830e35c5103
📒 Files selected for processing (2)
app/components/Code/Viewer.vueapp/pages/package-code/[[org]]/[packageName]/v/[version]/[...filePath].vue
app/pages/package-code/[[org]]/[packageName]/v/[version]/[...filePath].vue
Show resolved
Hide resolved
app/pages/package-code/[[org]]/[packageName]/v/[version]/[...filePath].vue
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
🧹 Nitpick comments (1)
app/pages/package-code/[[org]]/[packageName]/v/[version]/[...filePath].vue (1)
588-603:@screenusage now correct; minor responsiveness consideration remains.The
@screen lgdirective is correctly placed at top-level (not nested), addressing the previous review feedback. The switch from100vwto100%is also appropriate.However,
.file-viewerwidth applies at all breakpoints, whilst.file-treeis only visible onmd+screens. On mobile, this subtracts sidebar space for a hidden element. Theflex-1class should compensate viaflex-grow, but consider scoping the width rule tomd+for clarity:Option: Scope width rules to md+ breakpoint
.file-tree { width: var(--sidebar-space); } +@screen md { + .file-viewer { + width: calc(100% - var(--sidebar-space)); + } +} -.file-viewer { - width: calc(100% - var(--sidebar-space)); -}Alternatively, since
.file-vieweralready hasflex-1 min-w-0in the template, the explicit width may be unnecessary if flexbox sizing is sufficient.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d420e8f0-1328-42ad-968d-7926a66f68b3
📒 Files selected for processing (2)
app/components/Code/Viewer.vueapp/pages/package-code/[[org]]/[packageName]/v/[version]/[...filePath].vue
|
A toggle would be nice and also line numbers should adapt Example comparison https://npmx.dev/package-code/grammy/v/1.41.1/out%2Fbot.d.ts https://npmx-axzqrskfc-npmx.vercel.app/package-code/grammy/v/1.41.1/out%2Fbot.d.ts |
|
Switching to Draft because the line numbers need to be recomputed. As attempted in |
|
the wrapping is very readable and atm I also only see the issue of the line numbers & the highlighting included with it. a file that may be good to check would be in nuxt the /dist/index.mjs file because it has large imports |
🔗 Linked issue
Attempts to resolve 2027
🧭 Context
The current approach has overflow-x-auto, but wrapping might be better.
It's unclear whether that's preferred, so making the PR to allow a preview.
📚 Description
We actually can compute available screen width, so we can avoid overflow, and instead set the width and use flex-wrap combined with pre-wrap to get the desired effect.
Potential points of contention / concerns
I didn't visually test the highlighting, I'm yet unsure what the implications would be :)