Spaces:
Running
Running
create a project management that features centralize work with flexible views (List, Board, Calendar, Timeline), robust task management (dependencies, custom fields, subtasks), powerful automation (rules, workflows), team collaboration tools (Inbox, comments, status updates), and advanced reporting (dashboards, portfolios) to provide visibility, accountability, and streamline projects from start to finish.
ea012db verified Download components/task-item.js from jcondes0829/workflowwizard-pro: direct link, hf CLI and curl.
- Browser
- Download file 14 kB
-
https://huggingface.co/spaces/jcondes0829/workflowwizard-pro/resolve/main/components/task-item.js
- Command line
-
hf download hf://spaces/jcondes0829/workflowwizard-pro/components/task-item.js
-
curl -L -o task-item.js https://huggingface.co/spaces/jcondes0829/workflowwizard-pro/resolve/main/components/task-item.js
14 kB
| class CustomTaskItem extends HTMLElement { | |
| constructor() { | |
| super(); | |
| this.title = this.getAttribute('title') || 'Untitled Task'; | |
| this.project = this.getAttribute('project') || 'No Project'; | |
| this.dueDate = this.getAttribute('due-date') || ''; | |
| this.priority = this.getAttribute('priority') || 'medium'; | |
| this.assignee = this.getAttribute('assignee') || 'unassigned'; | |
| this.completed = this.getAttribute('completed') === 'true'; | |
| } | |
| connectedCallback() { | |
| this.attachShadow({ mode: 'open' }); | |
| this.render(); | |
| } | |
| static get observedAttributes() { | |
| return ['title', 'project', 'due-date', 'priority', 'assignee', 'completed']; | |
| } | |
| attributeChangedCallback(name, oldValue, newValue) { | |
| if (oldValue !== newValue) { | |
| if (name === 'completed') { | |
| this.completed = newValue === 'true'; | |
| } else { | |
| this[name] = newValue; | |
| } | |
| this.render(); | |
| } | |
| } | |
| render() { | |
| const priorityColors = { | |
| 'high': { bg: 'bg-red-100', text: 'text-red-800', border: 'border-red-200' }, | |
| 'medium': { bg: 'bg-yellow-100', text: 'text-yellow-800', border: 'border-yellow-200' }, | |
| 'low': { bg: 'bg-green-100', text: 'text-green-800', border: 'border-green-200' } | |
| }; | |
| const priorityLabels = { | |
| 'high': 'High', | |
| 'medium': 'Medium', | |
| 'low': 'Low' | |
| }; | |
| const colors = priorityColors[this.priority] || priorityColors.medium; | |
| const formattedDate = this.dueDate ? Utils.formatDate(this.dueDate) : 'No due date'; | |
| const isOverdue = this.dueDate && new Date(this.dueDate) < new Date() && !this.completed; | |
| const assigneeInitials = this.getAssigneeInitials(); | |
| const assigneeColor = this.getAssigneeColor(); | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| :host { | |
| display: block; | |
| font-family: system-ui, -apple-system, sans-serif; | |
| } | |
| .task-item { | |
| background: white; | |
| border-radius: 0.75rem; | |
| border: 1px solid #e5e7eb; | |
| padding: 1.25rem; | |
| position: relative; | |
| transition: all 0.2s ease; | |
| } | |
| .task-item:hover { | |
| border-color: #d1d5db; | |
| box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); | |
| } | |
| .task-item.completed { | |
| opacity: 0.7; | |
| background: #f9fafb; | |
| } | |
| .task-item.completed .task-title { | |
| text-decoration: line-through; | |
| color: #9ca3af; | |
| } | |
| .task-checkbox { | |
| width: 1.25rem; | |
| height: 1.25rem; | |
| border-radius: 0.375rem; | |
| border: 2px solid #d1d5db; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| cursor: pointer; | |
| transition: all 0.2s ease; | |
| flex-shrink: 0; | |
| } | |
| .task-checkbox:hover { | |
| border-color: #9ca3af; | |
| } | |
| .task-checkbox.checked { | |
| background-color: #10b981; | |
| border-color: #10b981; | |
| } | |
| .task-checkbox.checked i { | |
| color: white; | |
| display: block; | |
| } | |
| .task-checkbox i { | |
| display: none; | |
| width: 0.875rem; | |
| height: 0.875rem; | |
| } | |
| .task-content { | |
| flex: 1; | |
| min-width: 0; | |
| } | |
| .task-title { | |
| font-weight: 500; | |
| color: #111827; | |
| margin-bottom: 0.375rem; | |
| display: flex; | |
| align-items: center; | |
| gap: 0.5rem; | |
| } | |
| .task-project { | |
| font-size: 0.875rem; | |
| color: #6b7280; | |
| display: flex; | |
| align-items: center; | |
| gap: 0.375rem; | |
| } | |
| .task-meta { | |
| display: flex; | |
| align-items: center; | |
| gap: 1rem; | |
| margin-top: 0.75rem; | |
| flex-wrap: wrap; | |
| } | |
| .task-priority { | |
| font-size: 0.75rem; | |
| padding: 0.25rem 0.625rem; | |
| border-radius: 9999px; | |
| font-weight: 500; | |
| display: inline-flex; | |
| align-items: center; | |
| gap: 0.25rem; | |
| } | |
| .task-due { | |
| font-size: 0.875rem; | |
| color: #6b7280; | |
| display: flex; | |
| align-items: center; | |
| gap: 0.375rem; | |
| } | |
| .task-due.overdue { | |
| color: #ef4444; | |
| font-weight: 500; | |
| } | |
| .task-assignee { | |
| width: 2rem; | |
| height: 2rem; | |
| border-radius: 50%; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| font-size: 0.75rem; | |
| font-weight: 600; | |
| color: white; | |
| margin-left: auto; | |
| } | |
| .task-actions { | |
| display: flex; | |
| gap: 0.5rem; | |
| margin-left: 1rem; | |
| } | |
| .task-action-btn { | |
| width: 2rem; | |
| height: 2rem; | |
| border-radius: 0.375rem; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| color: #6b7280; | |
| cursor: pointer; | |
| transition: all 0.2s ease; | |
| } | |
| .task-action-btn:hover { | |
| background-color: #f3f4f6; | |
| color: #374151; | |
| } | |
| @media (max-width: 640px) { | |
| .task-item { | |
| padding: 1rem; | |
| } | |
| .task-meta { | |
| gap: 0.75rem; | |
| } | |
| .task-actions { | |
| margin-left: 0.5rem; | |
| } | |
| } | |
| </style> | |
| <div class="task-item ${this.completed ? 'completed' : ''} ${'priority-' + this.priority}"> | |
| <div class="flex items-start gap-4"> | |
| <div class="task-checkbox ${this.completed ? 'checked' : ''}" data-task-toggle> | |
| <i data-feather="check" class="w-3.5 h-3.5"></i> | |
| </div> | |
| <div class="task-content"> | |
| <div class="task-title"> | |
| <span>${this.title}</span> | |
| ${this.hasSubtasks() ? ` | |
| <span class="text-xs px-1.5 py-0.5 bg-gray-100 text-gray-600 rounded">${this.getSubtaskCount()} subtasks</span> | |
| ` : ''} | |
| <div class="flex gap-1 ml-auto"> | |
| <span class="text-xs px-1.5 py-0.5 ${colors.bg} ${colors.text} rounded">${priorityLabels[this.priority]}</span> | |
| </div> | |
| <div class="task-project"> | |
| <i data-feather="folder" class="w-3.5 h-3.5"></i> | |
| <span>${this.project}</span> | |
| </div> | |
| <div class="task-meta"> | |
| <span class="task-priority ${colors.bg} ${colors.text} ${colors.border}"> | |
| <i data-feather="flag" class="w-3 h-3"></i> | |
| ${priorityLabels[this.priority]} | |
| </span> | |
| <div class="task-due ${isOverdue ? 'overdue' : ''}"> | |
| <i data-feather="calendar" class="w-3.5 h-3.5"></i> | |
| <span>${formattedDate}</span> | |
| ${isOverdue ? '<span class="ml-1">• Overdue</span>' : ''} | |
| </div> | |
| </div> | |
| </div> | |
| <div class="task-assignee" style="background-color: ${assigneeColor}" title="${this.getAssigneeName()}"> | |
| ${assigneeInitials} | |
| </div> | |
| <div class="task-actions"> | |
| <div class="task-action-btn" title="Add dependency"> | |
| <i data-feather="link"></i> | |
| </div> | |
| <div class="task-action-btn" title="Add subtask"> | |
| <i data-feather="plus-circle"></i> | |
| </div> | |
| <div class="task-action-btn" title="More options"> | |
| <i data-feather="more-vertical"></i> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| `; | |
| setTimeout(() => { | |
| feather.replace(); | |
| // Add checkbox click handler | |
| const checkbox = this.shadowRoot.querySelector('.task-checkbox'); | |
| if (checkbox) { | |
| checkbox.addEventListener('click', (e) => { | |
| e.stopPropagation(); | |
| this.toggleCompletion(); | |
| }); | |
| } | |
| // Add click handler for task item | |
| const taskItem = this.shadowRoot.querySelector('.task-item'); | |
| if (taskItem) { | |
| taskItem.addEventListener('click', (e) => { | |
| if (!e.target.closest('.task-checkbox') && !e.target.closest('.task-action-btn')) { | |
| window.location.href = `task-detail.html?id=${encodeURIComponent(this.title.toLowerCase().replace(/\s+/g, '-'))}`; | |
| } | |
| }); | |
| } | |
| // Add action button handlers | |
| const actionBtns = this.shadowRoot.querySelectorAll('.task-action-btn'); | |
| actionBtns.forEach((btn, index) => { | |
| btn.addEventListener('click', (e) => { | |
| e.stopPropagation(); | |
| this.handleAction(index); | |
| }); | |
| }); | |
| }, 100); | |
| } | |
| toggleCompletion() { | |
| this.completed = !this.completed; | |
| this.setAttribute('completed', this.completed); | |
| // Dispatch custom event | |
| this.dispatchEvent(new CustomEvent('task-toggled', { | |
| detail: { | |
| taskId: this.getAttribute('data-task-id'), | |
| completed: this.completed | |
| }, | |
| bubbles: true, | |
| composed: true | |
| })); | |
| } | |
| getAssigneeInitials() { | |
| const nameMap = { | |
| 'alex': 'AJ', | |
| 'sarah': 'SC', | |
| 'mike': 'MD', | |
| 'jane': 'JD', | |
| 'tom': 'TB' | |
| }; | |
| return nameMap[this.assignee] || this.assignee.slice(0, 2).toUpperCase(); | |
| } | |
| getAssigneeName() { | |
| const nameMap = { | |
| 'alex': 'Alex Johnson', | |
| 'sarah': 'Sarah Chen', | |
| 'mike': 'Mike Davis', | |
| 'jane': 'Jane Doe', | |
| 'tom': 'Tom Brown' | |
| }; | |
| return nameMap[this.assignee] || this.assignee; | |
| } | |
| getAssigneeColor() { | |
| const colors = ['#ef4444', '#3b82f6', '#10b981', '#8b5cf6', '#f59e0b', '#ec4899']; | |
| const index = ['alex', 'sarah', 'mike', 'jane', 'tom'].indexOf(this.assignee); | |
| return index >= 0 ? colors[index] : colors[Math.floor(Math.random() * colors.length)]; | |
| } | |
| hasSubtasks() { | |
| // In a real app, this would check actual subtask data | |
| return Math.random() > 0.5; | |
| } | |
| getSubtaskCount() { | |
| return Math.floor(Math.random() * 5) + 1; | |
| } | |
| handleAction(index) { | |
| const actions = ['dependency', 'subtask', 'more']; | |
| const action = actions[index]; | |
| switch(action) { | |
| case 'dependency': | |
| this.showDependencyModal(); | |
| break; | |
| case 'subtask': | |
| this.showSubtaskModal(); | |
| break; | |
| case 'more': | |
| this.showMoreOptions(); | |
| break; | |
| } | |
| } | |
| showDependencyModal() { | |
| console.log('Show dependency modal for task:', this.title); | |
| // In a real app, this would open a modal | |
| } | |
| showSubtaskModal() { | |
| console.log('Show subtask modal for task:', this.title); | |
| // In a real app, this would open a modal | |
| } | |
| showMoreOptions() { | |
| console.log('Show more options for task:', this.title); | |
| // In a real app, this would show a dropdown menu | |
| } | |
| } | |
| customElements.define('custom-task-item', CustomTaskItem); |