feat: add scroll spy progress highlighting to docs headings sidebar - #32
Merged
Conversation
Implements an Alpine.js scroll spy that tracks which heading is currently in view and marks all headings above it as "passed", giving the reader a visual progress indicator in the right sidebar.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a docs scroll‑spy: CSS introduces a passed/current state and dark variants; an Alpine.js Changes
Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@resources/js/app.js`:
- Around line 255-384: The livewire:navigated listener added in init() is never
removed, causing accumulation; change init()/setup() to store the handler
function reference (e.g., this.livewireNavigatedHandler = () => {
this.teardown(); this.$nextTick(() => this.setup()); }) and register
document.addEventListener('livewire:navigated', this.livewireNavigatedHandler),
then remove it in teardown() or destroy() with
document.removeEventListener('livewire:navigated',
this.livewireNavigatedHandler) and set this.livewireNavigatedHandler = null so
the listener is cleaned up when the component is torn down.
In `@resources/views/components/docs/headings.blade.php`:
- Around line 5-18: The navlist should be gated on the filtered collection and
"passed" should only mark headings above the active one: change the outer
conditional to check the computed $filteredHeadings (e.g. `@if`
(count($filteredHeadings) > 1)) so you don't render an empty/one-item nav, and
update the x-bind:data-passed expression in the docsScrollSpy loop to use strict
greater-than (activeIndex > {{ $index }}) instead of >= so the current heading
isn't marked passed; keep x-bind:data-current as activeIndex === {{ $index }}
and preserve the $filteredHeadings variable and docsScrollSpy usage.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
resources/css/app.cssresources/js/app.jsresources/views/components/docs/headings.blade.php
Store livewire:navigated listener reference so it can be properly removed in destroy(), preventing duplicate listeners on SPA navigation. Move heading filter outside @if so count check uses filtered headings; fix data-passed binding from >= to > so current item isn't marked passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
docsScrollSpycomponent that usesIntersectionObserverto track the active heading in viewdata-passedand the active heading withdata-currentfor a visual progress indicatordata-passedstate (softer color) distinct from the full activedata-currenttreatment, with dark mode variantsTest plan
wire:navigateand confirm the scroll spy resets and re-attaches