class BucketMasterButton extends HTMLElement {
static get observedAttributes() {
return ['variant', 'size', 'disabled'];
}
constructor() {
super();
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
`;
}
connectedCallback() {
const button = this.shadowRoot.querySelector('button');
const variant = this.getAttribute('variant') || 'primary';
const size = this.getAttribute('size') || 'medium';
const disabled = this.hasAttribute('disabled');
button.classList.add(variant, size);
button.disabled = disabled;
}
attributeChangedCallback(name, oldValue, newValue) {
const button = this.shadowRoot.querySelector('button');
if (name === 'variant') {
button.classList.remove(oldValue);
button.classList.add(newValue);
}
if (name === 'size') {
button.classList.remove(oldValue);
button.classList.add(newValue);
}
if (name === 'disabled') {
button.disabled = newValue !== null;
}
}
}
customElements.define('bucketmaster-button', BucketMasterButton);