BookStack icon indicating copy to clipboard operation
BookStack copied to clipboard

Expand chapters in book view by default

Open DaveFace opened this issue 6 years ago • 17 comments

Describe the feature you'd like It would be useful to have the chapters (in book view) expanded by default, to give a clearer idea of a book's content at first glance. Perhaps a per-book setting, or a global .env setting.

Describe the benefits this feature would bring to BookStack users Improves immediate readability and discovery, making it easier to find what you're looking for without hunting through multiple drop-downs.

DaveFace avatar Dec 03 '18 01:12 DaveFace

You can achieve that by using the CSS override in custom head field:

<style>
.inset-list {
    display: block !important;
}
.page-list .text-muted {
    display: none !important;
}
</style>

I did some more css changes in the overview and now it looks like this: screenshot_2018-12-03_10-50-11

I like this much more because its simpler to have an overview about the available content, but it definitely depens on your project. In one of them I have the "problem" that there is very much pages and you definitely need the chapters only view. But there is much space to improve the list view, first of all I would like to replace the extra line for showing/hiding the pages screenshot_2018-12-03_11-12-28 this should be attached to the chapter line (I could not achieve that yet by only using css)

ezzra avatar Dec 03 '18 10:12 ezzra

That's fantastic @ezzra - thanks for posting that. I figured there might be a way to do it with a CSS override but I have no idea what I'm doing there.

I agree it will depend on the project, if you have a lot of chapters/pages this would become pretty cumbersome. For now though, mine's looking much neater!

Edit: I also found this was annoying me on the sidebar too, so after a bit of trial and error I found that adding:

.sidebar-page-list .text-muted {
    display: none !important;
}

It also hides them there.

DaveFace avatar Dec 03 '18 16:12 DaveFace

This does not appear to be hiding the "# pages" count anymore. Did the CSS names change that would allow the above code to hide that?

michaelmcdonald avatar Nov 03 '19 19:11 michaelmcdonald

@michaelmcdonald Just add this

button[chapter-toggle] {
    display: none !important;
}

JBauto avatar Dec 06 '19 15:12 JBauto

This works great for me:

    button[chapter-toggle] {
        display: none !important;
    }

    .inset-list {
        display: block !important;
    }

ryanmortier avatar Mar 25 '22 13:03 ryanmortier

Anybody found a way to expand the chapter by default but keep the button and option to collapse them again if needed ?

camaer avatar Mar 25 '22 15:03 camaer

@camaer This would open them up on page load in the current version of BookStack (Not assured for future versions):

<script>
window.addEventListener('DOMContentLoaded', (event) => {
    (window.components['chapter-toggle'] || []).forEach(toggle => {
    	toggle.open();
    	toggle.isOpen = true;
    })
});
</script>

ssddanbrown avatar Mar 26 '22 00:03 ssddanbrown

@ssddanbrown In version 22.06.1 the script no longer works. Is there a solution for this?

makrele568 avatar Jul 13 '22 20:07 makrele568

Here's the solution:

<script>
window.addEventListener('DOMContentLoaded', (event) => {
    (window.components['chapter-contents'] || []).forEach(toggle => {
    	toggle.open();
    	toggle.isOpen = true;
    })
});
</script>```

makrele568 avatar Jul 14 '22 08:07 makrele568

Since v22.11 and PR #3853, the previous solution doesn't work. By replacing by the new syntax, it seems to behave as intended:

window.addEventListener('DOMContentLoaded', (event) => {
	window.$components.get('chapter-contents').forEach(toggle => {
		toggle.open();
		toggle.isOpen = true;
	});
});

nathanaelhoun avatar Dec 29 '22 14:12 nathanaelhoun

I think this would be best implemented as a local user preference, like 'Toggle Details' on the home page, or 'Grid View' / 'List View' on the Shelves & Books pages.

Depending on the book that's being read, shelves may contain a lot of pages, or relatively few pages. If they contain few pages then my preference would be to expand chapters. For some books locating the right chapter (when you don't know the right thing to search for) is best done by scrolling through the book - therefore I would collapse chapters in that case. It's very context dependant.

I'm currently using the custom head HTML script, with the caveat that it apples to all users and is always defaulting to expand chapters.

I can understand how every new feature needs weighted against the overhead of implementing and maintaining. @ssddanbrown what's your opinion on whether such a feature is viable?

ajh0912 avatar Mar 25 '23 14:03 ajh0912

The below is working for me to force expand and also hide the "# pages" collapse/expand button

<style>
    .chapter-contents-toggle {
        display: none !important;
    }
    .inset-list {
        display: block !important;
    }
</style>

@ssddanbrown I would love to see this properly implemented as an option in settings if you ever have time.

ryland-mueller avatar May 26 '23 16:05 ryland-mueller

@ryland-mueller It's not really a matter of time, I generally avoid adding these kind of UI options to the app, preferring instead to expose generic methods of extension/customization as you have used here.

ssddanbrown avatar May 26 '23 16:05 ssddanbrown

I understand this sentiment. My only counterpoint would be that these tweaks tend to break over time, as seen in this thread. The snippet posted by @ryanmortier a year ago does not hide the dropdown button anymore, hence my update.

ryland-mueller avatar May 26 '23 16:05 ryland-mueller

This is a really good example for a very simple/small thing, that leads to much "check+update"-work on every update over years for multiple peoples, if it is implemented via visual theme system instead of being a System-Setting.

aka: i would vote for it being a System-Setting =)

demlak avatar Jun 19 '23 10:06 demlak

Agreed, this should be a setting - it's the best way to have the top chapters work as automatic table of contents pages, with all the pages effortlessly listed there, and always up to date.

It feels like such a natural way of using bookstack that it should be easier than using flaky custom code...

Thanks

pgorod avatar Jan 26 '24 19:01 pgorod