class StatsCard extends HTMLElement { static get observedAttributes() { return ['title', 'value', 'icon', 'color']; } constructor() { super(); this.attachShadow({ mode: 'open' }); } connectedCallback() { this.render(); } attributeChangedCallback(name, oldValue, newValue) { this.render(); } render() { const title = this.getAttribute('title') || ''; const value = this.getAttribute('value') || ''; const icon = this.getAttribute('icon') || 'alert-circle'; const color = this.getAttribute('color') || 'blue'; const colorClasses = { blue: { bg: 'bg-blue-50', text: 'text-blue-600' }, green: { bg: 'bg-green-50', text: 'text-green-600' }, orange: { bg: 'bg-orange-50', text: 'text-orange-600' }, indigo: { bg: 'bg-indigo-50', text: 'text-indigo-600' }, red: { bg: 'bg-red-50', text: 'text-red-600' }, yellow: { bg: 'bg-yellow-50', text: 'text-yellow-600' }, }[color]; this.shadowRoot.innerHTML = `
${title}
${value}
`; } } customElements.define('stats-card', StatsCard);