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

ENH: manage sidebars on small screens #726

Merged
merged 38 commits into from
Jul 10, 2022
Merged

Conversation

12rambau
Copy link
Collaborator

@12rambau 12rambau commented Jun 12, 2022

That's still a draft so i'll track down all the issues referencing this problem later.

Context

Lot's of people are complaining that the theme is not as responsive as they would expect on small devices. Specifically the sidebars both primary and secondary are a burden for everyone as they are not properly managed in the theme forcing people to discard them most of the time (specifically true for the secondary one).

proposal

In this PR I proposed to improve the design by transforming the 2 sidebars into drawers on small screens. One on the left and one on the right. without changing the interactivity that we already have on bigger screens

Enregistrement de l’écran 2022-06-12 à 17 54 31

TODO

  • make drawers closable on click outside
  • add a dark overlay to hide the content while opening a drawer
  • ensure only 1 of the 3 drawers can be opened at the time
  • correct scrolling bug in the drawer
  • tune the hide/show behavior between css and JS

Before I continue working on it I would like to have other feedback to see if this feature is useful or not. (to test it simply go to small screen the rest is behaving funny.

@choldgraf
Copy link
Collaborator

Agreed this one would be quite useful. A few relevant issues where this has been discussed:

In particular, I wrote out a little suggested implementation in the top comment here:

That is based on the pattern that Furo and the Sphinx Book Theme use. It is also similar to the approach that the sphinx-basic-ng theme takes (cc @pradyunsg).

As an example:

I think this would definitely be useful! Happy to help provide guidance on implementation if you're interested in this route.

@12rambau
Copy link
Collaborator Author

New version fully based on css. Could you test it from your side ? I'm pretty sure there are edge cases that I didn't catch

@12rambau 12rambau marked this pull request as ready for review June 20, 2022 22:19
Copy link
Collaborator

@choldgraf choldgraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is generally looking really nice! I made a few suggestions and comments in there but I think it would be a great improvement!

One thing we don't need to do now, but might explore over time if the header feels too cramped, is adding a secondary header that hides itself on wide screens, and put the sidebar toggle buttons in there.

@@ -2,17 +2,21 @@
* The primary sidebar on the left.
* e.g., between-pages navigation.
*/
.bd-sidebar {
.bd-sidebar-primary {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm +1 on this, but just a note that this will be a breaking change so we should note it in the release notes

@12rambau
Copy link
Collaborator Author

There are still issues with breakpoints as breakpoints-up and breakpoint-down are not behaving the same way. What do you think if I fix these values for both sidebars as layout variables ?

@choldgraf
Copy link
Collaborator

There are still issues with breakpoints as breakpoints-up and breakpoint-down are not behaving the same way. What do you think if I fix these values for both sidebars as layout variables ?

I'm not exactly sure what you mean by this, but if you're saying that we use $variables to accomplish the same thing manually, I think it's fine if it gets the result we want

@choldgraf
Copy link
Collaborator

choldgraf commented Jun 22, 2022

Looking better! A couple other quick comments:

  • On mobile, the presence of the left button is pushing all of the navigation links to the right:
    image
  • I think they're slightly too large...I think 1.2em looked a bit better to me. Also would help if they were a more muted color so they don't pop out so much.
  • The icons should be flipped horizontally I think. We want the arrow of the icon to be pointing in the direction that the draw will fly out.

I'll also note that I'm starting to feel like the header on mobile is quite "busy". It makes it feel less clean now that the logo is no longer right up against the left side. What do you think about either:

  • trying to put them beneath the header in their own small secondary header?
  • Putting the buttons inside the header dropdown, just after navbar-end?

Maybe that could resolve some of the above issues as well?

@12rambau
Copy link
Collaborator Author

  • So I reintroduced the toc_width_show parameter to unable different behaviours when the secondary sidebar is missing. I was forced to place it outside of the block elements in the layout.html so that any template have access to it (it's used in header-article, layout itself and secondary-sidebar). Using sass parameters, I can accept any value to this class (toc-show-xs, toc-show-sm….

  • Same for the primary sidebar. If one day we decide to make it a parameter we can change the variable in _variables.sass and all the relative elements will be modified together.

  • I realized that the squeezing were not synchronized everywhere. We were mixing breakpoint-up and breakpoint-down that doesn’t use the same limits. I choose to stick to breakpoint-up as it allows to use “xl”. (in breakpoint-down “xl” is equivalent to always). I tweeked all the calls to respect that.

  • I added a header-article navbar to display the 2 icons so that they don’t increase the number of things to display in the top navbar. this bar is covered when the top navbar is expanded so that we can't open sidebars and top navbar at the same time.
    Enregistrement de l’écran 2022-06-22 à 22 13 45

@12rambau 12rambau changed the title manage sidebars on small screens ENH: manage sidebars on small screens Jun 23, 2022
@choldgraf choldgraf marked this pull request as draft July 7, 2022 09:44
@choldgraf
Copy link
Collaborator

choldgraf commented Jul 7, 2022

OK I made a little bit of progress here, just pushed a commit that reworks the sidebar logic a little bit, but I think there is still more to be done. The spacing is a little bit off, and the buttons don't show up at quite the right time, but it is an iterative improvement I hope 😬 (also merged main in)

I can try to keep thinking on this one, but just wanted to push the work thus far for transparency and so we don't accidentally make a big merge conflict

@choldgraf choldgraf marked this pull request as ready for review July 7, 2022 14:17
@choldgraf
Copy link
Collaborator

choldgraf commented Jul 7, 2022

OK I think that I got this working! Wanna take a look? In the GIF below I'm showing going from wide to mobile width, and you can see the sidebar elements collapsing into buttons. I then click on the "home page" which shows both buttons not appearing because there are no sidebars on that page.

chrome_ZQ10EjJ17A
?

@12rambau
Copy link
Collaborator Author

12rambau commented Jul 7, 2022

That's excellent

Correct me if I'm wrong but the offset to leave space for the article-header is never changed even when no header is on the page right ? That's not a problem to me just want to make sure that it's a feature

@choldgraf
Copy link
Collaborator

Correct me if I'm wrong but the offset to leave space for the article-header is never changed even when no header is on the page right ? That's not a problem to me just want to make sure that it's a feature

I think that's true - I figured that it would look weird if the titles of pages jumped up and down based on whether there were going to be sidebars.

@12rambau
Copy link
Collaborator Author

12rambau commented Jul 8, 2022

I fixed the test for the new sidebar implementation, I think we cannot test the behaviour in the current tests, that will be something for #585 I'm happy with the curent state, @choldgraf thanks for your help!

@choldgraf
Copy link
Collaborator

Ah thanks for fixing the test!

Hmm, so what do you think we should do about this PR re: the next release? I think it seems in pretty good shape, should we get it into v0.10? Or hold off until that is released before merging this one in?

My feeling is that we'll need to make a release candidate with this release anyway, so that could provide some time for others to provide feedback on the sidebar behavior.

What do you or others think?

@12rambau
Copy link
Collaborator Author

12rambau commented Jul 8, 2022

I'm timeline agnostic.Although It's a big change but highly requested one (many documentations are playing with their custom css to avoid the primary sidebar to end up on top of the page on small screen). I think it's ready to go. Happy to hear others feelings about it being shiped with v0.10

@choldgraf
Copy link
Collaborator

anybody else have thoughts on #726 (comment) ?

cc @jorisvandenbossche @jarrodmillman @drammock @bryevdv @tupui

@tupui
Copy link
Contributor

tupui commented Jul 8, 2022

Oh waou this is great! Since it's a major improvement, I would not delay it.

Otherwise it seems intuitive. I am just not sure if it should not stick when you scroll (maybe a floating object like rdt is doing?). In any case it can be continued in another iteration.

@drammock
Copy link
Collaborator

drammock commented Jul 8, 2022

I'd say put it in the RC, don't wait until after release.

@choldgraf
Copy link
Collaborator

OK in that case, I think we should merge this in a day or two (ideally after an iteration of comments from somebody :-) )

@choldgraf
Copy link
Collaborator

OK unless anybody objects I'll plan to merge this one later today or tomorrow, and then we can get feedback from folks in new issues etc

@choldgraf choldgraf merged commit 177c05e into pydata:main Jul 10, 2022
@choldgraf
Copy link
Collaborator

OK let's merge this one and iterate a bit!

@12rambau 12rambau deleted the sidebars branch July 11, 2022 06:12
This was referenced Jul 13, 2022
@jarrodmillman jarrodmillman modified the milestones: 0.11, 0.10 Jul 26, 2022
@@ -86,6 +87,11 @@
/* Between-page links and captions */
nav.bd-links {
font-size: var(--pst-sidebar-primary-font-size);
margin-right: -1rem;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@12rambau do you remember why you styled nav.bd-links (the nav element containing the section navigation links) to have margin-right: -1rem? (Aside: can you tell me what the bd- prefix means?)

I can plainly see and understand why you set the negative -1rem margin for the in-page TOC in the right sidebar (it's so that the vertical notch that indicates the current section is aligned properly), but so far I haven't been able to figure out what the -1rem margin is doing for the left sidebar. (On the left sidebar, the current section notches are not aligned to any vertical line.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the bd- prefix is the bootstrap one that they use usually in their demo examples. it's a very old issue but for the release of version 1 we would like to get rid of them #37.

About the -1rem I guess the only way to find out is to remove it 😄

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

Successfully merging this pull request may close these issues.

Sidebar Layout on Mobile Left sidebar / table of contents toggle drawer on mobile
6 participants