Repository navigation
feat(flame): show reading progress in the mobile toc bar - #472
Merged
Merged
Conversation
A circular progress indicator now sits to the left of the current section's title, inline in the mobile bar's table of contents button. - It fills with the share of sections reached: the active heading's position among the page's headings. - It completes at the end of the page, since a short last section never scrolls up to the anchor offset and so never becomes active. - 18px ring: a faint track and a primary arc. At 0 only the track is drawn, so the round cap shows no dot. The fill animates, except under prefers-reduced-motion. - The ring is decorative. The button's accessible name carries the percentage, e.g. "Expand table of contents, 56% of sections read". - No ring on pages without headings. Above the first heading the bar now shows the page title, as the desktop TOC does. It kept the last active section after scrolling back to the top, which would contradict a ring at 0. The `if (currentId)` guard came from the IntersectionObserver version, where nothing visible could mean "between headings". In the scroll-based version it only means "above the first heading".
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the whole PR in standard mode (a UI island, not on the build/render, security or plugin path). It adds a reading progress ring to the mobile TOC bar and makes the bar show the page title above the first heading.
tocProgresshelper: a pure function inTocProgress.tsxthat returns the active heading's position among the page's headings. It is clamped to 0..1, returns 0 when there are no headings and 1 at the end of the page.TocProgressCircle: an 18px decorative SVG ring witharia-hidden. It draws no arc at 0, and its dash-offset transition is turned off undermotion-reduce.MobileBarscroll tracking: the handler now records the active index and whether the page is scrolled to the end. It also callssetActiveId(null)above the first heading, which matchesToc.tsxon desktop.- Accessible name: when headings exist, the TOC button's
aria-labelnow ends with the percentage, for example ", 56% of sections read". - Tests and changeset: 9 unit tests for the math and the markup, plus a
@docubook/flamepatch changeset. A patch bump matches how this repo has shipped other UI features.
What I checked:
- Mobile scroll source:
#scroll-containeronly scrolls internally atlgand up (lg:overflow-y-auto). On mobile the window scrolls, sowindow.scrollYanddocumentElement.scrollHeightare the right values foratEnd. - Hydration:
#mobile-bar-islandis an empty div in the SSR output, so state that exists only on the client cannot cause a hydration mismatch. - Validation:
toc-progress.test.tspasses (9 of 9) andoxlintreports nothing on the three changed source files.
claude-opus-5-5 | 𝕏
This was referenced Nov 5, 2026
Merged
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
The mobile docs bar now shows reading progress. A small circular indicator sits to the left of the current section's title, inline in the bar's table of contents button.
Behavior
base-contenttrack and aprimaryarc. At 0 only the track is drawn, so the round cap shows no dot. The fill animates itsstroke-dashoffset, except underprefers-reduced-motion.aria-hidden. The button's accessible name carries the percentage, for example "Expand table of contents, 56% of sections read".Related fix
Above the first heading, the bar now shows the page title, as the desktop TOC does. It used to keep the last active section after scrolling back to the top, which would contradict a ring at 0%. The
if (currentId)guard came from the IntersectionObserver version, where "nothing visible" could mean "between headings". In the scroll-based version, no active heading only happens above the first one.Code
.docu/components/TocProgress.tsx:tocProgress(activeIndex, total, atEnd)andTocProgressCircle..docu/components/Sidebar.tsx:MobileBartracks the active heading's index and the end of the page, and renders the ring before the title.Verification
Built flame's docs and scrolled
docs/getting-started/base-pathtop to bottom and back in Chromium, emulating a 390px phone with touch, in the light and dark themes.toc-progress.test.tscover the progress math and the ring markup: position, end of page, clamping, no arc at 0, the dash offset,aria-hiddenand the reduced-motion class.tsc,oxlint, the docs build and the pre-push hook pass.