class CloudElement extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); } connectedCallback() { const text = this.getAttribute('text') || ''; const percentage = this.getAttribute('percentage') || '0'; this.shadowRoot.innerHTML = `
${text} ${percentage}%
`; // Set cloud size based on percentage const cloudBody = this.shadowRoot.querySelector('.cloud-body'); const baseSize = 120; const size = baseSize * (0.7 + (parseInt(percentage) / 150)); cloudBody.style.width = `${size}px`; cloudBody.style.height = `${size * 0.7}px`; } } customElements.define('custom-cloud', CloudElement);