From 5564dad820a5f821558626b595c14fb5cfd59e2c Mon Sep 17 00:00:00 2001 From: Andrew Tatomyr Date: Sun, 19 Oct 2025 20:51:42 +0300 Subject: [PATCH 1/2] feat(todo): make stale tasks pale; fix subtasks color and sanitize them --- package.json | 2 +- .../purity-todo/components/subtask-item.ts | 10 ++++++---- .../components/task-details-style.ts | 14 ++++++++++++-- .../purity-todo/components/task-item.ts | 18 +++++++++++++----- .../purity-todo/components/task-list-style.ts | 11 +++++++++++ src/examples/purity-todo/manifest.json | 2 +- src/examples/purity-todo/purity-todo.sw.ts | 2 +- 7 files changed, 45 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index fd9e8f4..a6426f0 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "scripts": { "json-server": "json-server --watch public/examples/json-server/db.json", "test": "vitest src/", - "coverage": "vitest run src/ --coverage", + "coverage": "vitest run src/ --coverage.enabled", "e2e": "bash bin/e2e.sh", "cypress": "npx cypress@14.0.0 open --config baseUrl=http://localhost:8081", "prettier:check": "npx prettier --check \"**/*.{ts,html,yaml,css,md,json}\"", diff --git a/src/examples/purity-todo/components/subtask-item.ts b/src/examples/purity-todo/components/subtask-item.ts index 9e9e26c..8240839 100644 --- a/src/examples/purity-todo/components/subtask-item.ts +++ b/src/examples/purity-todo/components/subtask-item.ts @@ -26,7 +26,9 @@ const handleSubtaskChange = patchTask({ id: task.id, subtasks: task.subtasks?.map((subtask, i) => - i === subtaskIndex ? {...subtask, description: value} : subtask + i === subtaskIndex + ? {...subtask, description: sanitize(value)} + : subtask ), }) } @@ -44,7 +46,7 @@ export const subtaskItem = ( ): string => { return render`
-
+
${description}
` : render` - render` height: min(90vw, 33vh); max-height: min(90vw, 33vh); transition: height .2s ease-in; - + background-size: cover; background-repeat: no-repeat; background-position: center; @@ -44,7 +44,7 @@ export const taskDetailsStyle = (): string => render` .task-details--description { flex-grow: 1; - background: #f0f0f0; + background: var(--background-color); } .description-edit, .subtask-input { @@ -52,6 +52,8 @@ export const taskDetailsStyle = (): string => render` padding: 4px 8px; border: none; height: 2rem; + background: var(--background-color); + color: var(--text-color); } .subtask { @@ -61,6 +63,14 @@ export const taskDetailsStyle = (): string => render` gap: 8px; } + .subtask-completed { + text-decoration: line-through; + width: 100%; + padding: 4px 8px; + color: var(--text-color); + opacity: 0.6; + } + .${SMALL_BUTTON} { width: 2rem; min-width: 2rem; diff --git a/src/examples/purity-todo/components/task-item.ts b/src/examples/purity-todo/components/task-item.ts index ca7b0e8..69ea6e9 100644 --- a/src/examples/purity-todo/components/task-item.ts +++ b/src/examples/purity-todo/components/task-item.ts @@ -41,24 +41,32 @@ export const taskItem = ({ description, id, completed, + updatedAt, image, subtasks = [], }: Task) => render` -
  • +
  • 7 * 24 * 60 * 60 * 1000 ? "stale" : ""} + " + > -
    ${description.trim()} ${subtasks.filter(({checked}) => !checked).map(subtaskItem)}
    -