docs: Highlight reader's position in table of contents #1262
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.
While browsing the documentation, I often become disoriented because
the table of contents is so long, and there's no connection between it
and the content I'm viewing.
To make it easier for readers to orient themselves, navigation links in
the table of contents are emphasized when their respective section is
being viewed by the user.
To accomplish this,
<section>
tags have been wrapped around all thecontent. (I also took the liberty of using
<article>
and<nav>
where it was appropriate.) When the page's DOM is loaded, some
JavaScript runs that:
IntersectionObserver
.IntersectionObserver
.When a section moves in or out of the viewport, a callback adds or
removes a
visible-section
class to the associated navigation link.Known Issues:
header_open|close
should probably be renamed tosection_open|close
. I have not done that yet since it would bloatthe diff and make the functional changes harder to review.
<section>
. It looksa bit odd, so some CSS might be needed.