class ProgressRing extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); } static get observedAttributes() { return ['value', 'color', 'size']; } connectedCallback() { this.animateValue(); } attributeChangedCallback(name, oldValue, newValue) { if (oldValue !== newValue && this.shadowRoot) { this.render(); this.animateValue(); } } render() { const value = this.getAttribute('value') || 0; const color = this.getAttribute('color') || '#10b981'; const size = this.getAttribute('size') || 150; this.shadowRoot.innerHTML = ` `; } animateValue() { const circle = this.shadowRoot.querySelector('.progress-ring__circle'); const value = parseInt(this.getAttribute('value') || 0); const radius = circle.r.baseVal.value; const circumference = radius * 2 * Math.PI; circle.style.strokeDasharray = `${circumference} ${circumference}`; const offset = circumference - (value / 100) * circumference; setTimeout(() => { circle.style.strokeDashoffset = offset; }, 100); } } customElements.define('progress-ring', ProgressRing);