class CustomProjectCard extends HTMLElement { constructor() { super(); this.title = this.getAttribute('title') || 'Untitled Project'; this.progress = parseInt(this.getAttribute('progress')) || 0; this.dueDate = this.getAttribute('due-date') || ''; this.members = parseInt(this.getAttribute('members')) || 0; this.tasks = parseInt(this.getAttribute('tasks')) || 0; this.color = this.getAttribute('color') || 'primary'; } connectedCallback() { this.attachShadow({ mode: 'open' }); this.render(); } static get observedAttributes() { return ['title', 'progress', 'due-date', 'members', 'tasks', 'color']; } attributeChangedCallback(name, oldValue, newValue) { if (oldValue !== newValue) { if (name === 'progress') { this.progress = parseInt(newValue); } else if (name === 'members' || name === 'tasks') { this[name] = parseInt(newValue); } else { this[name] = newValue; } this.render(); } } render() { const colorClass = this.color === 'primary' ? 'primary' : this.color; const colorMap = { 'primary': { bg: 'bg-primary-100', text: 'text-primary-800', progress: 'bg-primary-600' }, 'blue': { bg: 'bg-blue-100', text: 'text-blue-800', progress: 'bg-blue-600' }, 'green': { bg: 'bg-green-100', text: 'text-green-800', progress: 'bg-green-600' }, 'purple': { bg: 'bg-purple-100', text: 'text-purple-800', progress: 'bg-purple-600' }, 'yellow': { bg: 'bg-yellow-100', text: 'text-yellow-800', progress: 'bg-yellow-600' } }; const colors = colorMap[colorClass] || colorMap.primary; const formattedDate = this.dueDate ? Utils.formatDate(this.dueDate) : 'No due date'; const relativeDate = this.dueDate ? Utils.formatRelativeDate(this.dueDate) : ''; this.shadowRoot.innerHTML = `

${this.title}

Due ${formattedDate} • ${relativeDate}
${this.progress}% Complete
${this.members} Members
${this.tasks} Tasks
${this.getPriority()} Priority
`; setTimeout(() => { feather.replace(); // Add click handler const card = this.shadowRoot.querySelector('.project-card'); if (card) { card.addEventListener('click', () => { window.location.href = `project-detail.html?id=${encodeURIComponent(this.title.toLowerCase().replace(/\s+/g, '-'))}`; }); } }, 100); } getPriority() { if (this.progress >= 75) return 'Low'; if (this.progress >= 50) return 'Med'; if (this.progress >= 25) return 'High'; return 'Urgent'; } } customElements.define('custom-project-card', CustomProjectCard);