Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ html, body {
.project-card {
background: white;
border: 1px solid var(--border-color);
border-top: 4px solid #3b82f6;
border-radius: 0.5rem;
padding: 1.5rem;
cursor: pointer;
Expand Down
2 changes: 1 addition & 1 deletion e2e/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ test.describe('Task Manager App', () => {
await page.click('#addProjectBtn');
await page.fill('#projectName', 'Website Redesign');
await page.fill('#projectDescription', 'Redo the company website');
await page.selectOption('#projectColor', 'green');
await page.fill('#projectColor', '#10b981');
await page.click('#projectForm button[type="submit"]');

await expect(page.locator('#projectModal')).not.toHaveClass(/active/);
Expand Down
8 changes: 1 addition & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,7 @@ <h3>Project Details</h3>
</div>
<div class="form-group">
<label for="projectColor">Color Tag</label>
<select id="projectColor">
<option value="blue">Blue</option>
<option value="red">Red</option>
<option value="green">Green</option>
<option value="yellow">Yellow</option>
<option value="purple">Purple</option>
</select>
<input type="color" id="projectColor" value="#3b82f6">
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Save Project</button>
Expand Down
22 changes: 19 additions & 3 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -965,13 +965,29 @@ class TaskManager {
});
}

normalizeColor(color: string | undefined): string {
const colorMap: Record<string, string> = {
blue: '#3b82f6',
red: '#ef4444',
green: '#10b981',
yellow: '#f59e0b',
purple: '#a855f7'
};
const defaultColor = '#3b82f6';
if (!color) return defaultColor;
const resolved = colorMap[color] || color;
return /^#[0-9a-fA-F]{3,6}$/.test(resolved) ? resolved : defaultColor;
}

renderProjectCard(project: { id: string; name: string; description?: string; color?: string }): string {
const tasks = storage.getTasks().filter(t => t.projectId === project.id);
const completed = tasks.filter(t => t.completed).length;
const percentage = tasks.length === 0 ? 0 : Math.round((completed / tasks.length) * 100);

const borderColor = this.normalizeColor(project.color);

return `
<div class="project-card ${project.color || 'blue'}" data-project-id="${project.id}">
<div class="project-card" style="border-top-color: ${borderColor}" data-project-id="${project.id}">
<div class="project-title">${project.name}</div>
${project.description ? `<div class="project-description">${project.description}</div>` : ''}
<div class="project-stats">
Expand Down Expand Up @@ -1009,7 +1025,7 @@ class TaskManager {
if (project) {
(document.getElementById('projectName') as HTMLInputElement).value = project.name;
(document.getElementById('projectDescription') as HTMLTextAreaElement).value = project.description || '';
(document.getElementById('projectColor') as HTMLSelectElement).value = project.color || 'blue';
(document.getElementById('projectColor') as HTMLInputElement).value = this.normalizeColor(project.color || 'blue');
deleteBtn.style.display = 'block';
}
}
Expand All @@ -1028,7 +1044,7 @@ class TaskManager {
const project = {
name: (document.getElementById('projectName') as HTMLInputElement).value,
description: (document.getElementById('projectDescription') as HTMLTextAreaElement).value,
color: (document.getElementById('projectColor') as HTMLSelectElement).value
color: (document.getElementById('projectColor') as HTMLInputElement).value
};

if (this.currentEditingProjectId) {
Expand Down
Loading