class UiButton extends HTMLElement { static get observedAttributes() { return ['variant', 'size', 'loading', 'disabled']; } connectedCallback() { this.#render(); } attributeChangedCallback() { this.#render(); } #render() { const variant = this.getAttribute('variant') || 'primary'; const size = this.getAttribute('size') || 'md'; const loading = this.hasAttribute('loading'); const disabled = this.hasAttribute('disabled') || loading; const pad = { sm: '.35rem .75rem', md: '.5rem 1rem', lg: '.65rem 1.25rem' }[size] || '.5rem 1rem'; const fs = { sm: '.813rem', md: '.875rem', lg: '1rem' }[size] || '.875rem'; if (!this.shadowRoot) this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = ` `; } } customElements.define('ui-button', UiButton);