UNPKG

natura11y

Version:

Natura11y is an open-source design system for creating beautiful web interfaces with a focus on accessible interaction design and front-end development.

24 lines (18 loc) 512 B
import { delegateEvent } from './utilities/eventDelegation'; export default class Alert { // Private methods #handleAlertClose = (event) => { event.preventDefault(); const alert = event.target.closest('.alert'); if (alert) { alert.classList.add('dismissed'); alert.addEventListener('animationend', () => { alert.remove(); }); } }; // Public methods init = () => { delegateEvent(document, 'click', '[data-alert-close]', this.#handleAlertClose); }; }