Repository navigation
feat(sidebar): Mobile default improvements - #907
Merged
Merged
Conversation
…vars All are named `--bslibs-sidebar-mobile-*` breaking(python): Changes internal css property to `--_mobile-max-height` for consistency
cpsievert
reviewed
Nov 16, 2023
cpsievert
reviewed
Nov 16, 2023
cpsievert
reviewed
Nov 16, 2023
cpsievert
reviewed
Nov 16, 2023
cpsievert
reviewed
Nov 16, 2023
and is called directly by the `_initDesktop` method
cpsievert
reviewed
Nov 16, 2023
cpsievert
approved these changes
Nov 16, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The biggest change in this PR is to avoid a CSS animation for sidebars with
open="desktop"when initializing the sidebar on mobile screen sizes. With this default,layout_sidebar()provides initially correct markup for open sidebars, but we close the sidebar when initialized. Previously, we would use the exact same code path as if the user had clicked the collapse toggle, but this caused a distracting animation on page load.We now instead skip the transition – mostly use the same code path – but without adding the
.transitioningclass. In this way, the sidebar closes immediately but we don't lose the aria labels and other appropriate accessibility markup that we require. Here's a sketch of those changes:open="desktop", on small screens, we now add the collapsed class, without including the.transitioningclass and immediately invoke_finalizeState()..transitioningclass is added before the state-changing class is toggled. This is achieved by enabling--_transition-durationonly when the.transitioningclass is added.hiddento theopen="desktop"sidebar element. We remove this attribute if the sidebar should be open. This prevents some layout jumps from happening if the sidebar's contents are briefly shown before being closed.While in this area, I also:
Added
--bslib-sidedbar-mobile-max-width,--bslib-sidebar-mobile-opacityand--bslib-sidebar-mobile-box-shadowCSS custom properties that be set globally (or--_sidebar-mobile-*for locally scoped changes). We don't use these yet, but they open the door for working with design variations of the sidebar on mobile.I adjusted the sidebar transition duration default from
500msto300msfor a snappier transition.