-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Floating Table of Contents for longer docs (ToC) #6896
Comments
Hi @fk I put this in the Docs redesign phase 3 EPIC, open to discussion on how to prioritize it! |
👍 |
@shannonbux you might be interested in checking out this Gatsby starter I've been working on which implements a floating TOC like you've described. I can't remember exactly why it wasn't sufficient for my use case, but my implementation does not make use @DSchau's TOC plugin |
Hi @johncmunson, cool starter! I don't see the floating TOC yet - am I missing something? Also, just realizing this issue could be split into two
Finally, have you submitted your starter to the starter library yet? |
@shannonbux it only displays on larger screen widths. You may need to drag the browser wider than the full width of your screen. My implementation utilizes To get the IntersectionObserver api to work on mobile (b/c even though the TOC doesn't display on mobile, I'm still updating the URL hash as the user scrolls), I needed to
I haven't yet added to the starter library, will be sure to do that when my starter is feature complete. |
@johncmunson that would be excellent. @fk Do you think there would be enough whitespace in docs to implement something like this? This isn't necessarily a top priority, unless @johncmunson you want to work on it! |
@shannonbux Yep, I think starting from at around 1300px viewport width we should have enough whitespace. |
Sounds pretty fun, I'll take a look this week and see what I come up with! |
sounds great!
…On Mon, Dec 17, 2018 at 7:49 AM John Munson ***@***.***> wrote:
Sounds pretty fun, I'll take a look this week and see what I come up with!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6896 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Ae9o2tunWHEIEvFYuOw8CyNxJYmIs7hqks5u57z4gaJpZM4VoqGN>
.
|
Not stale! |
@shannonbux, @marcysutton and I brainstormed on this today and we came up with some ideas on how we could implement this. On large displays, we have room on the right side of the page to have a sticky section on the right side of the screen that we could have to notify people of their current place in the current document and it would stay in place as we scroll down the document. Below I show how we will take the table of contents out of the normal flow of the document and into a sidebar-like area: As well, on mobile, we could keep the TOC in the flow of the document but move it up to right under the main heading of the page: @fk we'd appreciate some feedback if this feels alright or if there may be a better way to display a table of contents on each form-factor. |
💯, it does! IMO for the first shot we don't even need to worry too much about making the ToC sticky when it's displayed as a "sidebar", although it'd be nice to have! FWIW here's something similar I did recently: We now have |
I just coded up a floating ToC very similar to what is being discussed here. You can check it out in action here. Here's the code. It relies on #13972. |
Some more information and success criteria from our specification doc: A floating table of contents widget will help users contextualize where they are in a document, dynamically listing page sections and scrolling with them as they read. The floating TOC should include a heading like “Table of Contents” to be consistent with the Gatsby Preview docs. It should also include a list of internal links to each of the h2, h3, and possibly h4 headings in the document (need to play around with this–it might be nice to make it configurable). All text colors should be evaluated to meet color contrast requirements (4.5:1 for smaller, non-bold text). The widget could potentially leverage Remark plugins. It should live in the DOM source between the h1 heading and the article’s main body to allow it to float in the right column at large viewports and slide under the h1 heading on smaller viewports. Acceptance Criteria
|
Small update: The above mentioned ToC implementation no longer relies on #13972 and now highlights the currently active section of the document. Also wrote a short blog post about it. |
So I'm going to take a dive into implementing this issue this weekend. If I can get a PR up, I'll likely be contacting @fk for some design advice so it fits into the current site design and @marcysutton to make sure it's accessible. I will as well look into the implementations that @janosh did on his personal blog. |
@lannonbr |
@gagan0723 So we actually already have that functionality for the sidebar on mobile layouts in the various layouts to go between different pages. This issue is specifically for making a Table of Contents for different sections of a single page. |
@lannonbr Significant parts of the reactjs.org implementation could probably still be reused for in-page navigation. |
@calcsam idea: Quip writing app does this in a clean and clear way
The text was updated successfully, but these errors were encountered: