-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add Card
class and migrate card JavaScript to TypeScript
#557
Conversation
Apply click and transition end event listeners directly to the elements that need them instead of applying them to the document and relying on event delegation. We also now use vanilla JS to add and remove event listeners instead of jQuery, and we remove the event listeners if the layouts are removed the page.
arrive is a lot lighter and can be included in each component directly
Improves the transition animation
we just use it for the types in bslib components
It's now a part of Card class
1. Properties 2. Constructor 3. Public methods 4. Private methods 5. Static methods
Makes it easier to test without using overly complex selectors
Three biggish changes to callout since the last review:
|
Co-authored-by: Carson Sievert <[email protected]>
Co-authored-by: Carson Sievert <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
Ported in posit-dev/py-shiny@f8e5a20 |
Depends on #555.
Related to #517.
Fixes #558.
This PR adds a new
Card
class that moves the card initialization JavaScript into TypeScript. I also consolidated the full screen toggle JavaScript into this class, since we were only using it via thecard()
API.This PR also brings initialization (#555) and ResizeObserver improvements (#566) from sidebars to cards.
Further improvements to the card component include localized event listeners, rather than relying on a global event listener. This gave us a chance to fix #558 and ensure that we expand the correct card and that we only expand one card at a time – this part is made possible in part by adding a
.bslib-has-full-screen
to the document body to prevent expanding other cards.While in full screen, the card component will trap keyboard focus in the full screen area, ensuring that focus doesn't leak to other parts of the document body. I'll add specific tests for this case in follow-up PR in shinycoreci, but for testing you can use the app below.
Tab Focus App
This PR is accompanied by to two PRs in other repos:
Add Shiny Event classes for custom events shiny#3815
Because we're adding an event handler for a custom Shiny event,"shiny:value"
, we needed to provide the appropriate overloads to associate"shiny:value"
with theShinyEventValue
interface. While looking into that, I refactored Shiny's custom event code.This PR no longer relies on Add Shiny Event classes for custom events shiny#3815. In Add ShinyResizeObserver #566 we created ShinyResizeObserver which uses the RO concept first used for cards but without relying on a shiny event.
Update 304-bslib-card shinycoreci#160
I updated the example card app and modified the tests in
shinytest2: 304-bslib-card
, in part for easier testing and in part because I moved the listener node for the exit fullscreen event handler. (In short, clicking anywhere outside the full screen card will close the card, like modal witheasyClose = TRUE
.)