class NotificationComponent extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = `
`; } connectedCallback() { this.closeBtn = this.shadowRoot.querySelector('.close-btn'); this.closeBtn.addEventListener('click', () => this.hide()); } show(type, message, duration = 5000) { this.setAttribute('class', type); // Custom messages for email notifications if (type === 'error') { message = 'Could not send an email! Please try again later.'; } else if (type === 'success') { message = 'We have sent you an email. Please check your inbox. If you cannot view it in your primary inbox, please check your Spam or Junk folder.'; } this.innerHTML = message; const icon = this.shadowRoot.querySelector('.icon i'); icon.setAttribute('data-feather', type === 'success' ? 'check-circle' : 'alert-triangle'); this.classList.add('show'); if (duration > 0) { setTimeout(() => this.hide(), duration); } } hide() { this.classList.remove('show'); setTimeout(() => this.remove(), 300); } } customElements.define('notification-component', NotificationComponent);