Skip to content

feat: add scroll spy progress highlighting to docs headings sidebar - #32

Merged
loadinglucian merged 4 commits into
mainfrom
feat/docs-headings-scroll-spy
Feb 25, 2026
Merged

feat: add scroll spy progress highlighting to docs headings sidebar#32
loadinglucian merged 4 commits into
mainfrom
feat/docs-headings-scroll-spy

Conversation

@loadinglucian

Copy link
Copy Markdown
Owner

Summary

  • Adds an Alpine.js docsScrollSpy component that uses IntersectionObserver to track the active heading in view
  • Marks headings above the current position with data-passed and the active heading with data-current for a visual progress indicator
  • Adds CSS for data-passed state (softer color) distinct from the full active data-current treatment, with dark mode variants
  • Tears down observers on Livewire SPA navigation and re-initialises for new page content

Test plan

  • Scroll through a docs page and verify headings in the right sidebar highlight progressively as you pass them
  • Verify the active heading is visually distinct from "passed" headings
  • Verify dark mode styles apply correctly
  • Navigate between pages via wire:navigate and confirm the scroll spy resets and re-attaches
  • Scroll to the bottom of a long page and confirm the last heading becomes active

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.
@coderabbitai

coderabbitai Bot commented Feb 24, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ebe4714 and 11c5936.

📒 Files selected for processing (2)
  • app/Console/Commands/DocsClearCommand.php
  • app/Models/User.php

📝 Walkthrough

Walkthrough

Adds a docs scroll‑spy: CSS introduces a passed/current state and dark variants; an Alpine.js docsScrollSpy component tracks headings with IntersectionObserver and SPA re-init; headings template is filtered and bound to per-item progress state; small IDE/meta and IDE helper updates included.

Changes

Cohort / File(s) Summary
CSS Styling
resources/css/app.css
Adds [data-passed] styles for flux navlist items, preserves/upgrades [data-current] styles, switches hover selectors to exclude passed items, and adds matching dark‑mode rules.
Scroll Spy Component
resources/js/app.js
Adds Alpine.data('docsScrollSpy') implementing activeIndex, headingIds, an IntersectionObserver, scroll listener, SPA livewire:navigated reinit, and public init/setup/teardown/destroy methods; preserves existing livewire lightbox hook.
Template Bindings
resources/views/components/docs/headings.blade.php
Filters headings to level ≤3 with IDs, wraps nav in x-data="docsScrollSpy", iterates with index, and binds data-passed and data-current per item based on activeIndex.
IDE Meta
.phpstorm.meta.php
Adds 'storage.local.upload' to the PhpStorm registerArgumentsSet('routes', ...) list.
IDE Helper
_ide_helper.php
Adds facade helper methods for temporary upload URLs: providesTemporaryUploadUrls() and temporaryUploadUrl(...) on \Illuminate\Filesystem\Filesystem.
Attributes on Classes
app/Console/Commands/DocsClearCommand.php, app/Models/User.php
Adds #[\Override] PHP attributes to existing protected properties ($signature, $description, $fillable, $hidden)—no behavioral changes.

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding scroll spy progress highlighting to the docs headings sidebar, which is the primary feature across all modified files.
Description check ✅ Passed The description is directly related to the changeset, explaining the Alpine.js component, data attributes, CSS styling, and SPA navigation handling that are all present in the code changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between bce7561 and 4d1bda2.

📒 Files selected for processing (3)
  • resources/css/app.css
  • resources/js/app.js
  • resources/views/components/docs/headings.blade.php

Comment thread resources/js/app.js
Comment thread resources/views/components/docs/headings.blade.php Outdated
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.
@loadinglucian
loadinglucian merged commit 4bd3b89 into main Feb 25, 2026
7 checks passed
@loadinglucian
loadinglucian deleted the feat/docs-headings-scroll-spy branch February 25, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant