Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Commit 21e2a3c

Browse files
authored
WIP Todo app (#10)
* Start todo app article * Start todo app * Wordsmith * TodoBlank * Add example todo * Start todo list * Point arrow * Continue * Update CodeResult * Set up reducer * Show todo data * Finish slide 2 * Mark all as completed * Fix imports * 📝 * Continue with todo * Updated data/ui graphics * Add custom document * Temp commit * Continue w/ todo * 📝 * Highlight changes * Highlight changes * ResultHighlight * Wordsmith * Simplify * 📝 * Wordsmith * Wordsmith * 📝 * Preview todo article * 📝 * Fix todo list * Only show heading when length > 0 * Continue with slide 5 * Finish readonly * Wordsmith * Wordsmith
1 parent 76b068d commit 21e2a3c

File tree

15 files changed

+326
-23
lines changed

15 files changed

+326
-23
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy to github pages branch
1+
name: Deploy to Zeit Now
22
on:
33
push:
44
branches:

snippets/snippets/todo/dqwb.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function toggleTodo(todo: Todo): Todo {
2+
// Little Duckling’s refactoring
3+
todo.done = !todo.done
4+
return todo
5+
}

snippets/snippets/todo/njgr.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function toggleTodo(todo: Todo): Todo {
2+
// Little Duckling’s refactoring is a
3+
// bad refactoring because it modifies
4+
// the original todo object
5+
todo.done = !todo.done
6+
return todo
7+
}

snippets/snippets/todo/qbgu.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Returns a new todo object
2+
// with the opposite boolean value
3+
// for the "done" proprty.
4+
function toggleTodo(todo) {
5+
// ...
6+
}

snippets/snippets/todo/uxlb.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function toggleTodo(todo: Todo): Todo {
2+
// Little Duckling’s refactoring
3+
todo.done = !todo.done
4+
return todo
5+
}

snippets/snippets/todo/vgnq.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This will continue to work because
2+
// the input todo is not modified
3+
function toggleTodo(todo: Todo): Todo {
4+
return {
5+
id: todo.id,
6+
text: todo.text,
7+
done: !todo.done
8+
}
9+
}

snippets/snippets/todo/wymp.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const originalTodo = {
2+
id: 1,
3+
text: '…',
4+
done: true
5+
}
6+
7+
console.log('Before toggleTodo()…')
8+
console.log(originalTodo)
9+
10+
const newTodo = toggleTodo(originalTodo)
11+
12+
console.log('After toggleTodo()…')
13+
console.log('Original Todo:')
14+
console.log(originalTodo)
15+
console.log('New Todo:')
16+
console.log(newTodo)

snippets/snippets/todo/yhto.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
type Todo = {
2+
readonly id: number
3+
readonly text: string
4+
readonly done: boolean
5+
}

src/components/ArticleList.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const ArticleList = ({
7777
const filteredArticleKeys = articleKeys.filter(
7878
articleKey => articleKey !== ignoreArticleKey
7979
)
80-
return (
80+
return filteredArticleKeys.length > 0 ? (
8181
<>
8282
<h4
8383
css={css`
@@ -113,6 +113,8 @@ const ArticleList = ({
113113
))}
114114
</ul>
115115
</>
116+
) : (
117+
<></>
116118
)
117119
}
118120

src/components/CodeBlock.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const CodeBlock = ({
9595
resultVisible &&
9696
resultError
9797
? 'none'
98-
: `3px solid ${colors('darkOrange')}`};
98+
: `2px solid ${colors('darkOrange')}`};
9999
text-decoration: ${shouldHighlightResult &&
100100
resultVisible &&
101101
resultError

0 commit comments

Comments
 (0)