/** * Category Card Component * Displays a category with an icon and title * Icon is centered above the category text */ class CategoryCard extends HTMLElement { static get observedAttributes() { return ["title", "href", "icon"]; } constructor() { super(); this.attachShadow({ mode: "open" }); } connectedCallback() { this.render(); } attributeChangedCallback() { if (this.shadowRoot) { this.render(); } } get title() { return this.getAttribute("title") || "Category"; } get href() { return this.getAttribute("href") || "#"; } get icon() { return this.getAttribute("icon") || ""; } render() { const iconHtml = this.icon ? `${this.title}` : `
`; this.shadowRoot.innerHTML = ` ${iconHtml}

${this.title}

`; } } customElements.define("category-card", CategoryCard);