class ToolCard extends HTMLElement {
static get observedAttributes() {
return ['title', 'description', 'icon', 'category', 'link'];
}
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
this.render();
}
attributeChangedCallback(name, oldValue, newValue) {
this.render();
}
render() {
const title = this.getAttribute('title') || 'Tool Name';
const description = this.getAttribute('description') || 'Tool description goes here';
const icon = this.getAttribute('icon') || 'tool';
const category = this.getAttribute('category') || 'Category';
const link = this.getAttribute('link') || '#';
this.shadowRoot.innerHTML = `
${title}
${description}
${category}
`;
// Replace feather icons after rendering
if (this.shadowRoot.querySelector('[data-feather]')) {
feather.replace();
}
}
}
customElements.define('tool-card', ToolCard);