feat(sidebar): Redesign sidebar toggle and mobile layout#798
feat(sidebar): Redesign sidebar toggle and mobile layout#798
Conversation
Co-authored-by: Carson Sievert <cpsievert1@gmail.com>
Co-authored-by: Carson Sievert <cpsievert1@gmail.com>
|
Don't feel an obligation to respond if it's a complex answer, but I'm curious: why did the sidebar toggle change? Without knowing the context of this change, the new toggle button seems to me less ideal, because now it (1) takes up precious vertical real estate from the side bar which makes the top of the sidebar look empty, and (2) takes horizontal real estate from the main content when the sidebar is collapsed, which similarly makes the main content are look a bit awkward by having the left side be non symmetric with the right side. |
|
Hi @daattali! The changes were motivated by a few things all coming together. Above all, we wanted to orient the toggle at the top, rather than the bottom, and to have the sidebar expand to fill the full container width on mobile. Those both motivated the change in position and the new behavior where the toggle floats into and out of the sidebar. We too noted the symmetry issues and are planning on addressing that before release. We also felt that the previous design was overly compact and the usability suffered. The new toggle has a much bigger touch target. Along these lines, a common design thread in our latest work is to create more breathing room and space in default Shiny apps. We appreciate the feedback! If you're able to share specific examples from your work, either as screenshots or reprex apps, we'd love to take a look and take them into consideration. |
|
I don't have any specific examples, the screenshots from the docs website are enough - when I saw those, my first reaction was that these screenshots must be from a very old draft version. But I definitely understand it's extremely difficult or impossible to have an ideal design for this that works across all contexts. When I saw this image: I thought that it would maybe be nicer if the button the button was half in the sidebar and half in the main content, and then the sidebar content could be pushed up to the top and the main content could be centered horizontally, something like this And for mobile, Would become This is just what came to mind, but I realize these may have the same issues you describe initially, of the button not being prominent enough |
|
It does look like there's a bug in those screenshots. The left gutter between the sidebar and the content should not be constant, it's increased when the sidebar is collapsed, but returns to normal when the sidebar is open. Either the screenshots are missing the right edge of the app or there's a bug in the (version used for the) screenshots. Regardless, we'll be addressing the asymmetry in a follow-up PR soon. |




TODO
arrow-bar-leftfor the toggle icon--bslib-collapse-toggle-border-radiusthat can be used to set this.sidebar(position = "right")?max_height_mobilenow only applies toopen = "always"sidebars and is ignored otherwise. A warning is provided ifmax_height_mobileis provided with anotheropenvalue.Intro
This PR revisits the sidebar toggle with a new design and some updated behavior. At a high level:
Toggle moves to the top of the sidebar. When collapsed, the toggle is outside the sidebar area and when expanded the toggle moves into the sidebar area.
To accomodate this, we hold space in two places:
The colors of the main content area are now controlled via CSS variables,
--bslib-sidebar-main-fgand--bslib-sidebar-main-bg. I think this is a better pattern anyway, but it allows the toggle icon to be colored according to the foreground color of the region where its placed. (Previously it was static and only used the sidebar fg/bg colors.)Mobile view is completely revisited, ultimately it's much simpler. The sidebar operates in the same way (expands from the side), but takes up the complete layout area as an overlay over the main content area. Only one sidebar can be expanded at a time, so nested sidebars in the mobile view are simplified.
Demo App
Here's the code for a demo app to test features, appearance, etc. None of the controls are wired up, they're just there to help motivate appearance discussions.
Demo app with bunches of sidebars