Skip to content

Add CSS animation hooks (is-entering / is-leaving) to BLX Modal#10

Merged
liampmccabe merged 2 commits intomainfrom
copilot/add-animation-customizations-modal
Mar 3, 2026
Merged

Add CSS animation hooks (is-entering / is-leaving) to BLX Modal#10
liampmccabe merged 2 commits intomainfrom
copilot/add-animation-customizations-modal

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 3, 2026

The modal had no lifecycle class hooks, making it impossible to animate open/close transitions for the backdrop or dialog without overriding internals.

Changes

packages/modal/index.js (v1.1.0)

  • Two new state classes added to [blx-el="modal-popup"]:
    • is-entering — present during the open animation; removed on animationend/transitionend
    • is-leaving — present during the close animation; all teardown (ARIA, focus restore, DOM reposition) deferred until animation completes
  • waitForAnimation(el, callback) helper:
    • Inspects getComputedStyle for animation-duration / transition-duration; parses comma-separated multi-value lists and uses the longest
    • No animation detected → fires immediately (zero behaviour change for existing installs)
    • Animation detected → listens for animationend + transitionend with a called guard, plus a setTimeout fallback for interrupted/display-toggled cases
  • Closing during an in-progress enter animation cancels is-entering cleanly before adding is-leaving

packages/modal/README.md

  • New Animations section: class lifecycle table, @keyframes example animating backdrop and dialog independently, CSS transition example, and a note on enter-direction behaviour.

Usage

/* Backdrop */
[blx-el="modal-popup"].is-entering { animation: backdrop-in  0.25s ease forwards; }
[blx-el="modal-popup"].is-leaving  { animation: backdrop-out 0.20s ease forwards; }

/* Dialog (child element) */
[blx-el="modal-popup"].is-entering .modal-content { animation: dialog-in  0.3s cubic-bezier(0.34,1.56,0.64,1) forwards; }
[blx-el="modal-popup"].is-leaving  .modal-content { animation: dialog-out 0.2s ease forwards; }

@keyframes backdrop-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes backdrop-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes dialog-in    { from { opacity: 0; transform: translateY(-20px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes dialog-out   { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(10px) scale(0.97); } }

No CSS defined → instant open/close as before.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@liampmccabe liampmccabe marked this pull request as ready for review March 3, 2026 11:02
Co-authored-by: liampmccabe <3018957+liampmccabe@users.noreply.github.com>
@liampmccabe liampmccabe merged commit eebadb0 into main Mar 3, 2026
Copilot AI changed the title [WIP] Add animation customizations to modal component Add CSS animation hooks (is-entering / is-leaving) to BLX Modal Mar 3, 2026
Copilot stopped work on behalf of liampmccabe due to an error March 3, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants