class ArchAppIcon extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
this.render();
this.setupInteraction();
}
static get observedAttributes() {
return ['name', 'icon', 'package'];
}
render() {
const name = this.getAttribute('name') || 'App';
const icon = this.getAttribute('icon') || 'box';
this.shadowRoot.innerHTML = `
${name}
`;
// Re-initialize feather icons for shadow DOM
if (window.feather) {
feather.replace({
parent: this.shadowRoot,
width: 24,
height: 24
});
}
}
setupInteraction() {
this.addEventListener('click', () => {
const name = this.getAttribute('name');
const package = this.getAttribute('package');
this.dispatchEvent(new CustomEvent('launch-app', {
bubbles: true,
composed: true,
detail: { name, package }
}));
// Visual feedback
this.classList.add('launching');
setTimeout(() => this.classList.remove('launching'), 400);
});
}
}
customElements.define('arch-app-icon', ArchAppIcon);