Skip to content

Collapsible sidebar #2159

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

Merged
merged 17 commits into from
Mar 25, 2025
Merged

Conversation

gabalafou
Copy link
Collaborator

@gabalafou gabalafou commented Mar 7, 2025

Fixes #1072.

Screenshot showing vertical and horizontal alignment guidelines:

image

@gabalafou
Copy link
Collaborator Author

I made the following accessibility checks:

  • No animation if user has set prefers-reduced-motion: reduce
  • Screen reader can read both expanded and collapsed state of button
  • Focus rings and keyboard functionality work
  • Minimum 24 x 24 px hit area for mouse click

@gabalafou gabalafou force-pushed the 1072-sidebar-collapse-widescreen branch from 2a0e7c0 to 817ec63 Compare March 10, 2025 18:05
@gabalafou
Copy link
Collaborator Author

Update: I have incorporated feedback from @smeragoel. The only thing left to do with this PR is to add a bare minimum of tests, and then I will mark it ready for review. I will not be able to get to writing tests until next week.

@trallard trallard added kind: enhancement New feature or request tag: component Issues or improvements associated with a given component in the theme labels Mar 12, 2025
@dprada
Copy link

dprada commented Mar 17, 2025

I am really looking forward to this implementation. Thanks @gabalafou and @smeragoel. 👏🏻

@drammock
Copy link
Collaborator

Update: I have incorporated feedback from @smeragoel.

Note to whoever merges this: please add @smeragoel as co-authored-by

@gabalafou gabalafou force-pushed the 1072-sidebar-collapse-widescreen branch from 92186ce to b766196 Compare March 21, 2025 22:56
@gabalafou gabalafou marked this pull request as ready for review March 21, 2025 22:56
@gabalafou
Copy link
Collaborator Author

Okay, I added tests. This is now ready for review.

trallard
trallard previously approved these changes Mar 24, 2025
Copy link
Collaborator

@trallard trallard left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @gabalafou and thanks for adding the tests.

I did not spot anything major, but left a message about reusing existing test sites to try and avoid adding too many sites, especially since we already have one for sidebars testing.

@gabalafou
Copy link
Collaborator Author

@trallard thank you for review! I think I responded and addressed all of your comments. The PR now needs another round of review and then hopefully it will be good to go! :)

@gabalafou
Copy link
Collaborator Author

gabalafou commented Mar 24, 2025

About the failing link check

The link check is expected to fail because there is a page in the docs that contains links to each of the component files in GitHub. This PR introduces a new component: sidebar-collapse. But the GitHub URL to this new component will not be live until this PR is merged.

But there was one unexpected thing. The link check reports several gnu.org links as broken. But I suspect those might just have been a network fluke, because when I go to the links, they work. The error message for all four of those links looks roughly the same:

HTTPConnectionPool(host='www.gnu.org', port=80): 
  Max retries exceeded with url: /software/gettext/ 
  (Caused by 
    NewConnectionError(
      '<urllib3.connection.HTTPConnection object at 0x7fc13020ae70>: 
      Failed to establish a new connection: [Errno 101] Network is unreachable'
    )
  )

@drammock
Copy link
Collaborator

The link check reports several gnu.org links as broken.

those have been failing regularly for over a week now at least. Currently 🙈 but hopefully fixed by #2174

Copy link
Collaborator

@trallard trallard left a comment

Choose a reason for hiding this comment

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

Thanks @gabalafou 🚀 this is a rather exciting new feature.
Will wait for the CI to complete and we can merge this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for making the configuration explicit 🌻

@trallard
Copy link
Collaborator

trallard commented Mar 25, 2025

The link check reports several gnu.org links as broken.

those have been failing regularly for over a week now at least. Currently 🙈 but hopefully fixed by #2174

These fail only on CI (but not always), and they might be related to some robots.txt or something else, as link check uses requests under the hood.
I might add the gnu URLS to the list of skipped URL checks to avoid the flaky errors.

That aside, this PR looks ready to merge so will wait for the rest of the CI to complete and merge it 🚀

@trallard trallard merged commit 21a1870 into pydata:main Mar 25, 2025
30 of 31 checks passed
@pllim
Copy link
Contributor

pllim commented Mar 25, 2025

Ooo thanks! What release will this be in?

@trallard
Copy link
Collaborator

Should be in the next release @pllim (still to decide when this will be out #2176)

@gabalafou gabalafou deleted the 1072-sidebar-collapse-widescreen branch March 25, 2025 13:26
border-right: 1px solid var(--pst-color-border);
background-color: var(--pst-color-background);
overflow-y: auto;
overflow: hidden auto;
Copy link
Collaborator Author

@gabalafou gabalafou Mar 25, 2025

Choose a reason for hiding this comment

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

Note to self: this is the one change that I worry about having unintended consequences. I don't see any reason why the primary sidebar should scroll in the horizontal direction and show a horizontal scroll bar, but I may not be aware of some sites or configurations that need the primary sidebar to scroll along the x axis.

Copy link
Collaborator Author

@gabalafou gabalafou Mar 25, 2025

Choose a reason for hiding this comment

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

(The reason why I don't think it needs horizontal scroll is that the section table of contents is configured to reflow, and ethical ads are also responsive.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

This can happend when creating API documentation. By design sphinx will use the full path to the method/class you want to describe which can become very very long if unchecked. I have created an example myself. I faced the problem when I was doing this: https://geetools.readthedocs.io/en/stable/autoapi/geetools/index.html and I was forced to change the template which is not straightfoward for new users. I know the title can be responsive as well but I find it easier to understand when things remain on 1 single line (at least for API names)

Copy link
Collaborator

Choose a reason for hiding this comment

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

True, this is one such instance where we'd have horizontal overflow.
@12rambau would it be possible to see how the new feature would render for your API docs? I am curious on whether we will be hitting some unexpected behaviours.

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 currently travelling with only my phone so I cannot really make checks outside of the github realm and building this documentation requires a new release from my side. I'll let you know once I'm back home and I can locally do a test

Copy link
Collaborator

Choose a reason for hiding this comment

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

No rush at all. Thanks for considering.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

By design sphinx will use the full path to the method/class you want to describe which can become very very long if unchecked.

Yeah, we can see that on the PST API docs page with the long method name pydata_sphinx_theme.edit_this_page.

I believe the alternative would be to force the method name on one line which, if the primary sidebar is narrow enough, will cause part of the string to be hidden on the right side (in the sidebar's overflow). That means the user will have to scroll horizontally in order to see the rest of the name. That feels to me like it makes the table of contents even harder to absorb visually than if the method name is broken across two or more lines.

Here are two screenshots to show the difference.

No wrapping

With the page a bit narrow and text wrapping turned off, the user can only make out "edit this pa":

With wrapping

With the page a bit narrow and with text wrapping enabled, the user can see the entire method name:

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like the text wrap even if it looks a bit chunky at least you see everything.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the wrapping is fine, I do not expect this to be a very frequent situation, and if it causes problems we can reevaluate/iterate.

@gabalafou
Copy link
Collaborator Author

I came back to this PR because I suddenly thought I had forgotten to include @smeragoel on the git commit co-authors, but then I realized that I didn't do the actual merge for this PR (@trallard did). Then I looked at the commit and saw the following at the bottom and it made me happy:

Co-authored-by: Daniel McCloy <[email protected]>
Co-authored-by: Tania Allard <[email protected]>
Co-authored-by: Smera Goel <[email protected]>

Thanks @drammock, @trallard, @smeragoel for all of your help, you are a great team!

🌻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement New feature or request tag: component Issues or improvements associated with a given component in the theme
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make it possible to collapse the primary sidebar on wide screens
6 participants