-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Indicators for sections in file tree menu #155
Comments
Hi again! I feel like icons on left might be an overkill, but indicator that section can be expanded might be good. Maybe a dot or triangle on right side of menu 🤔 |
@alex-shpak thanks for maintaining and supporting this and considering having this feature natively in the theme. I loved the simplicity of the theme and I believe many do and that's why are here :) Picture you've shown is the most simplistic implementation that looks perfectly clear without any bloat. I'd love to see ➡️ (state 3) when a section is collapsed ( ⬇️ (state 1) is nice to have as indenting already makes it clear that the menu items are under that section, however it'd probably go along pretty good with ➡️ cosmetically. |
I also think it's OK enough 👍🏿 Really huge thanks for it! I loved how clean the commit is 😲, I've been expecting much more lines :) I just tested it and it showed the bullet on every single menu item in Thanks again and very cool that you decided to have it natively 💗 Closing the issue now. |
Hi @alex-shpak , I know that now it's about different tastes, but when I compared on the right vs on the left I personally thought it looks better on the left as they are aligned. It gives a little bit chaotic look when they're not symmetrical. It may vary from person to person but I'd prefer to have them on the left. I did it now with some css override. You decide what to keep as default. Here's a picture of the site I'm building for comparison: |
Yeah, it might need tweaking. It kinda depends on how many collapsed items you have, in your case there are a lot so it looks better on left. Maybe on right image icons should be aligned and pushed to right edge.
So maybe it should be like
|
I pushed change to skip collapsed icon for leaf pages (even if |
Cool! 💡 Sass docs uses the bullet on right and aligns them as well. I think it's also a good option: https://sass-lang.com/documentation/syntax
I put pulled left each bulleted item, and then moved menu to the right with same margin to achieve it: .book-menu {
$arrow-margin: 1rem;
// Mark with "▸"
a {
&.collapsed {
&::before {
content: "▸";
margin-left: -$arrow-margin;
margin-right:0.3rem;
}
// Override the default
&::after { content: ""; margin-left: 0; }
}
}
// Fix alignment
ul {
margin-left: $arrow-margin;
ul {
margin-left:0; // Only affect parrent
}
} I also played with some SCSS to be able to write a query like: .open-section {
&::before {
content: "▾" !important;
}
} window.onload = markOpenSections;
function markOpenSections() {
const styleName = 'open-section';
const activeElement = document.getElementsByClassName('active','collapsed')[0];
styleParents(activeElement);
function styleParents(element) {
const isOpen = element.classList.contains('collapsed');
if(isOpen) {
element.classList.add(styleName);
}
const closestList = element.closest('ul');
if(!closestList) {
return;
}
const nextMenu = closestList.parentElement;
if(!nextMenu) {
return;
}
const nextItem = nextMenu.children[0];
if(!nextItem) {
return;
}
styleParents(nextItem);
}
}; |
I believe it's a big UX improvement that increases the usability as one could easily get a quick picture of the depth of the content.
It'd be achieved with three states: section (1), page (2) and a collapsed section (3). Here's an example from haxe
Or even more minimal example from Microsoft Docs:
It surely wouldn't look as clean as it is now but it's a trade-off I'd make for the reading experience.
You think it should be an optional feature of
hugo-book
? Or how would you recommend extending the theme to achieve that?The text was updated successfully, but these errors were encountered: