Skip to content

feat(components): add zero-JS ease-modal component (#251)#571

Open
bhavyabhardwaj001 wants to merge 1 commit into
SAPTARSHI-coder:mainfrom
bhavyabhardwaj001:feature/ease-modal-component
Open

feat(components): add zero-JS ease-modal component (#251)#571
bhavyabhardwaj001 wants to merge 1 commit into
SAPTARSHI-coder:mainfrom
bhavyabhardwaj001:feature/ease-modal-component

Conversation

@bhavyabhardwaj001
Copy link
Copy Markdown
Contributor

@bhavyabhardwaj001 bhavyabhardwaj001 commented May 31, 2026

Pull Request Description

Resolves #251.

This submission introduces a highly-performant, zero-JavaScript ease-modal component. It natively handles open states, close states, and backdrop-click-to-close entirely using the browser's URL hash and the CSS :target pseudo-class.


Type of Change

  • ✨ New animation / hover effect
  • 🧩 New component
  • 📝 Documentation improvement
  • 🐛 Bug fix in an existing submission
  • Other (describe below)

Submission Checklist

⚠️ PRs that fail this checklist will be closed without review.

  • All changes are inside submissions/examples/your-feature-name/
  • Includes demo.html — self-contained, opens in browser with no server
  • Includes style.css — raw CSS for the proposed feature
  • Includes README.md — what it does, how to use it, why it fits EaseMotion CSS
  • No changes to core/
  • No changes to components/
  • One feature per PR (no bundled unrelated changes)

Feature Description

What does this add?

A pristine CSS-only modal leveraging the :target selector.

How does a developer use it?

Give the .ease-modal-overlay a unique ID, and use an <a> tag pointing to that ID to open it.

<!-- Trigger -->
<a href="#my-modal" class="ease-btn ease-btn-primary">Open Modal</a>

<!-- Modal Structure -->
<div id="my-modal" class="ease-modal-overlay">
  <!-- Invisible backdrop click-to-close -->
  <a href="#" class="ease-modal-backdrop-close"></a>
  
  <div class="ease-modal-box">
    <!-- Close X button -->
    <a href="#" class="ease-modal-close">&times;</a>
    <h2>Modal Content</h2>
  </div>
</div>

Why does it fit EaseMotion CSS?

Modals are typically one of the most JS-heavy components in UI libraries, requiring event listeners for backdrop clicks and close buttons. This CSS-only implementation drastically reduces bundle size and JS execution time, perfectly aligning with the framework's CSS-first philosophy. Furthermore, it explicitly handles prefers-reduced-motion by gracefully falling back to a pure opacity fade rather than sliding/scaling in.


Demo

  • Demo added (demo.html works by opening directly in a browser)

Browser Testing

  • Chrome
  • Firefox
  • Edge
  • Safari (optional but appreciated)

Notes for Maintainer

I solved the "backdrop click to close" requirement without Javascript by placing a full-screen, invisible <a> tag (.ease-modal-backdrop-close) directly behind the .ease-modal-box that points to href="#". When clicked, it clears the target and naturally closes the modal!

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.

Add ease-modal component

1 participant