-
Notifications
You must be signed in to change notification settings - Fork 30
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
Table of Contents: Add toggle #389
Table of Contents: Add toggle #389
Conversation
@ryelle Here is the basic code but not sure how to inject JavaScript on the front-end for this. Is there a way with blocks or do I just need to call |
There's already a front end script for this block, it's at |
@ryelle Got it working. |
I've updated this PR with the styles suggested by @fcoveram. The table of contents is collapsed by default so that it's easy to skip. It's collapsed at all sizes, even when it's shifted to the sidebar, so that it is still skipped for screen reader users. This makes for kind of an awkward visual, with the only thing in the sidebar a toggle button. The alternative would be to have the table of contents expanded by default when the screen is wide enough (1200px). The list would still be collapsible, so a screen reader user can collapse it to get by. Would that be acceptable, @alexstine? Screenshots for design review:
|
Looks good to me. My only question would be whether we can have the table of contents be expanded by default, if you're on a large (two columns) screen. |
8f61c31
to
ecdf697
Compare
Accidentally added from the rebase merge conflict
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fcoveram Is that what it currently is, and it should be different? Can you tell me the values each side should be? |
Collapsed or expanded by default is fine, whichever way works better visually. Thanks. |
@ryelle I designed it with 15px for top and bottom paddings and 20px for left and right. But I understand that the outcome doesn't necessarily match Figma design, so adding a mockup with the spacing guides for reference. |
@fcoveram I think you're looking at the production site, the branch here has cleaned up some of those spacing issues. I just fixed it up a bit more so it should match your design now. (once this is merged, the templates in documentation & developers will need to updated to remove the attributes, since they're not necessary) |
…gh for it to be in the sidebar
Okay, I've set it to be expanded by default when the screen is large enough for the table of contents to be visually in the sidebar, otherwise it's collapsed by default. The toggle is there for all sizes. |
It looks great, thanks @ryelle. I was looking at the images you shared in this message 🤔 . Nonetheless, the last update works excellent. |
Adds a toggle for the Table of Contents block.
See WordPress/wporg-documentation-2022#58 for additional context.