jupyterlab-toc
jupyterlab-toc copied to clipboard
Add ToC indentation support
This PR resolves #114 by
- adding indentation to ToC entries
Notes
- This PR does not currently indent either code or Markdown entries for reasons of preserving full width rendering. If we indent code or Markdown, this could make the content illegible for small widths.
Screenshots
Collapsing enabled
![Screen Shot 2020-07-27 at 12 51 36 AM](https://user-images.githubusercontent.com/2643044/88517893-6be55800-cfa4-11ea-8969-bef511174446.png)
Collapsing enabled + numbering enabled
![Screen Shot 2020-07-27 at 12 51 51 AM](https://user-images.githubusercontent.com/2643044/88517902-6e47b200-cfa4-11ea-924f-c118baa2a94c.png)
Collapsing enabled + numbering enabled + code + Markdown
![Screen Shot 2020-07-27 at 12 58 31 AM](https://user-images.githubusercontent.com/2643044/88517912-70117580-cfa4-11ea-9cc9-41ce24fa3746.png)
Collapsing disabled
![Screen Shot 2020-07-27 at 1 02 28 AM](https://user-images.githubusercontent.com/2643044/88518197-eada9080-cfa4-11ea-9c94-fe8efbc767ef.png)
Collapasing disabled + numbering enabled
![Screen Shot 2020-07-27 at 12 56 53 AM](https://user-images.githubusercontent.com/2643044/88517904-6ee04880-cfa4-11ea-86b6-64a6b63ae0de.png)
Collapsing disabled + numbering enabled + code + Markdown
![Screen Shot 2020-07-27 at 12 57 26 AM](https://user-images.githubusercontent.com/2643044/88517910-6f78df00-cfa4-11ea-8edf-87c241f96292.png)
Something to think about from a visual design perspective is the a trees with indentation in a narrow panel start to be difficult at a certain depth. I think the proposed design here is making a good set of tradeoffs overall (reducing font size and lower depths, intending with a small amount of horizontal space).
@ellisonbg Thanks for taking a look. Instead of making this the default behavior, we could add an extension setting to allow users to toggle ToC indentation. Lack of ToC indentation has been a recurring request both on this repo, as well as internally. So offering the ability for users to opt-in to indentation seems like a reasonable compromise.
I agree it is useful and don't know it needs to be a setting (not opposed to it though). I do think it is a good default behavior as well. I was more encourage us to keep thinking about the tradeoffs and how we might make subtle visual changes to improve the overall experience while using indentation. I don't have specific recommendations, more of a general, let's keep exploring this as people start to use it.
@ellisonbg Sounds good! Thanks for your input!
Would it be possible to reduce the space between the lines in the TOC? I find the Jupyter TOC(2) extension is doing a good job on both horizontal and vertical spacing:
Just my 2c, but from a visual design perspective, I find the the diffrent font sizes of the different ToC levels extremely disorienting, especially coupled with same-sized collapse arrows. My guess is their original purpose was because we didn't have indentation, so something needed to indicate depth, but if we have indentation, maybe the font sizes can be made uniform, at least when code/markdown is off, when the disorientation is particularly bad? (just look how much better that TOC2 screenshot looks, at least to me)
Even if not, happy to see this PR, thank you!
Could you add in a little extra to cover indentation for toc of .py files?
See lines 17-22 here: https://github.com/hottwaj/jupyterlab-toc/blob/toc-indentation/src/generators/python/render.tsx
I guess something similar may also be needed for markdown & latex...
Thanks for this PR :)
jupyterlab/jupyterlab#9275 addresses this in the core extension. Maybe we should close this PR?
@kgryte I think you agree to close this PR, correct?
@ericdatakelly Depends on if people want/need this in a JLab version prior to ToC being merged into core. I don't necessarily see any harm in keeping the PR open indefinitely.