class CustomStatCard extends HTMLElement { constructor() { super(); } connectedCallback() { this.attachShadow({ mode: 'open' }); const title = this.getAttribute('title') || 'Metric'; const value = this.getAttribute('value') || '0'; const color = this.getAttribute('color') || 'green'; const icon = this.getAttribute('icon') || 'activity'; const trend = this.getAttribute('trend') || ''; const colorMap = { green: '#22c55e', orange: '#f97316', gold: '#ffd700', red: '#ef4444', blue: '#3b82f6', purple: '#a855f7' }; const accentColor = colorMap[color] || colorMap.green; let trendHtml = ''; if (trend) { const isPositive = trend.includes('+') || trend === 'record'; const isNegative = trend.includes('-'); const isNeutral = trend === 'stable'; if (isPositive) { trendHtml = `
${trend}
`; } else if (isNegative) { trendHtml = `
${trend}
`; } else { trendHtml = `
${trend}
`; } } this.shadowRoot.innerHTML = `
${title}
${value}
${trendHtml}
`; // Load feather icons for this component if (typeof feather !== 'undefined') { feather.replace(); } } } customElements.define('custom-stat-card', CustomStatCard);