Skip to content
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

Allow sections to be collapsed/expanded with a chevron-icon button #79

Open
PhilippMDoerner opened this issue Feb 26, 2023 · 2 comments

Comments

@PhilippMDoerner
Copy link
Contributor

PhilippMDoerner commented Feb 26, 2023

The Feature Suggestion

Allow the entries in the sidebar to be "folded in" and "out".

Motivation for this feature

Take this sidebar:
image

This is likely to grow in the future, making visibility of points below "internals" (and future longer sections) difficult.

It would be nice if I could "fold in" entries of the sidebar so that it can look more like this:
image

I would suggest this provide the following features:

1. Expand/Collapse on click icon - button

Every section is not just a hyperlink. To the left or right of the section entry in the sidebar should be an icon-button that a user could click on to expand/collapse a section of entries. For a consistent design language, the icons used should likely be chevron icons to indicate that it is currently collapsed (chevron-up) or expanded (chevron down).

The button should highlight on hover separate from the section-hyperlink.

2. Automatically expand section when user is in an entry of that section

In this example: If I am on the page "Build Hook", I would expect the section "Internals" and "Hooks" to be expanded, but not "Adders"

3. Side-consideration: Remove sections having their own pages and make their sole purpose to expand/collapse sections

It may be worth considering maybe making sections no longer their own page but only buttons to expand/collapse sections of a sidebar. That would be a breaking change.

Alternatively, it could be considered to keep section as is and introduce a new grouping mechanism going by the name of group, that you just pass the name it should have on the sidebar and whether the group should be expanded/collapsed initially.

@pietroppeter
Copy link
Owner

as nimibook is in its essence a port of mdbook the first place to look at is if this is implemented in mdbook.
From a quick search it appears it is indeed available: https://rust-lang.github.io/mdBook/format/configuration/renderers.html#outputhtmlfold

I have not yet checked how it is implemented in the code (and when it was implemented, we might need to catch up on the templates). It would also be nice to see a real example on how this implementation looks like when it is active.

@pietroppeter
Copy link
Owner

it appears it was implemented here in mdbook: rust-lang/mdBook#1027
since was before the moment nimibook was born, we might already have the feature hidden somewhere :)

anyway thanks for the input! I think it could be nice, not planning to work on this at the moment, but happy to help if someone wants to give it a try.

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

No branches or pull requests

2 participants