Experimental accordion-style sliding for TryExamples iframe panels, as a means to avoid content layout shift#338
Open
agriyakhetarpal wants to merge 4 commits intojupyterlite:mainfrom
Conversation
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.
Important
This is an experimental PR to gather feedback at this time. It is ready for review, but is not yet intended to be merged.
This PR introduces a refactor of the interactive example panel for accessibility reasons, i.e., to avoid content layout shifts that arise when a TryExamples directive button is clicked to replace the examples code snippet section with the JupyterLite iframe. With these changes, I would like to showcase an alternative approach. Instead of hiding/replacing the examples section, we keep it and expand the JupyterLite iframe, which slides down when the "Try it!" button is clicked. This means that while there is some duplication of examples, our accessibility improves overall, and we also have a nice iframe that slides down and slides back up. When the iframe is open, the "Try it!" button logically changes to a "Hide" button. IMO, the user's context is preserved: they can see the original example code snippets while interacting with the notebook, and they don't lose their place on the page because the page's elements don't jump around.
There are a couple of associated accessibility-related changes here, such as disabling animations when reduced motion is preferred and adding more ARIA attributes to indicate the iframe's expansion/contraction. I got them from reading this blog post: https://dev.to/grahamthedev/accessible-animated-accordion-in-pure-css-no-way-5980. We can bring the latter in its own separate PR if we decide not to go ahead with this approach.