class MessageBottomSheet extends HTMLElement { constructor() { super(); this.attachShadow({mode: 'open'}); this.shadowRoot.innerHTML = `
`; this.messageBottomSheet = this.shadowRoot.getElementById('messageBottomSheet'); this.messageContent = this.shadowRoot.getElementById('messageContent'); this.closeMessageButton = this.shadowRoot.getElementById('closeMessage'); this.overlay = this.shadowRoot.getElementById('overlay'); this.closeMessageButton.onclick = () => this.hideMessage(); this.overlay.onclick = () => this.hideMessage(); } showMessage(message) { this.messageContent.innerHTML = message.replace(/\n/g, '
'); this.messageBottomSheet.style.display = 'block'; this.overlay.style.display = 'block'; setTimeout(() => this.messageBottomSheet.classList.add('show'), 10); } hideMessage() { this.messageBottomSheet.classList.remove('show'); setTimeout(() => { this.messageBottomSheet.style.display = 'none'; this.overlay.style.display = 'none'; }, 300); } } customElements.define('message-bottom-sheet', MessageBottomSheet);