Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e84ef05
Start todo app article
chibicode Nov 23, 2019
c664ca8
Start todo app
chibicode Nov 24, 2019
4b2adbe
Wordsmith
chibicode Nov 24, 2019
8620882
TodoBlank
chibicode Nov 24, 2019
07986bf
Add example todo
chibicode Nov 24, 2019
dda1a8b
Start todo list
chibicode Nov 24, 2019
5460f58
Point arrow
chibicode Nov 25, 2019
7e42986
Continue
chibicode Nov 26, 2019
69f9350
Update CodeResult
chibicode Nov 27, 2019
cfac2d4
Set up reducer
chibicode Nov 27, 2019
d30631f
Show todo data
chibicode Nov 27, 2019
878849f
Finish slide 2
chibicode Nov 27, 2019
b22f557
Mark all as completed
chibicode Nov 27, 2019
ba49eef
Fix imports
chibicode Nov 27, 2019
7da359a
:pencil:
chibicode Nov 28, 2019
ab9239e
Continue with todo
chibicode Nov 28, 2019
755aa5e
Updated data/ui graphics
chibicode Nov 28, 2019
9414957
Add custom document
chibicode Nov 28, 2019
40554d4
Temp commit
chibicode Nov 28, 2019
67015a1
Merge branch 'master' into todo-app
chibicode Nov 29, 2019
8521360
Continue w/ todo
chibicode Nov 29, 2019
a4de4f2
:pencil:
chibicode Nov 29, 2019
faa9a04
Highlight changes
chibicode Nov 29, 2019
b7f2b41
Highlight changes
chibicode Nov 29, 2019
949d15c
ResultHighlight
chibicode Nov 29, 2019
9db5a5f
Wordsmith
chibicode Nov 29, 2019
3c0e2c9
Simplify
chibicode Nov 30, 2019
0578f09
:pencil:
chibicode Nov 30, 2019
c086045
Wordsmith
chibicode Nov 30, 2019
2844ca4
Wordsmith
chibicode Nov 30, 2019
921f9a5
:pencil:
chibicode Nov 30, 2019
90c6127
Preview todo article
chibicode Dec 1, 2019
421ad62
Merge branch 'master' into todo-app
chibicode Dec 1, 2019
275583c
:pencil:
chibicode Dec 1, 2019
0f01597
Fix todo list
chibicode Dec 5, 2019
e7afbd5
Only show heading when length > 0
chibicode Dec 5, 2019
b793977
Continue with slide 5
chibicode Dec 5, 2019
ca23393
Finish readonly
chibicode Dec 5, 2019
d1f8a7a
Wordsmith
chibicode Dec 5, 2019
34dcaf8
Wordsmith
chibicode Dec 5, 2019
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
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy to github pages branch
name: Deploy to Zeit Now
on:
push:
branches:
Expand Down
5 changes: 5 additions & 0 deletions snippets/snippets/todo/dqwb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function toggleTodo(todo: Todo): Todo {
// Little Duckling’s refactoring
todo.done = !todo.done
return todo
}
7 changes: 7 additions & 0 deletions snippets/snippets/todo/njgr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function toggleTodo(todo: Todo): Todo {
// Little Duckling’s refactoring is a
// bad refactoring because it modifies
// the original todo object
todo.done = !todo.done
return todo
}
6 changes: 6 additions & 0 deletions snippets/snippets/todo/qbgu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Returns a new todo object
// with the opposite boolean value
// for the "done" proprty.
function toggleTodo(todo) {
// ...
}
5 changes: 5 additions & 0 deletions snippets/snippets/todo/uxlb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function toggleTodo(todo: Todo): Todo {
// Little Duckling’s refactoring
todo.done = !todo.done
return todo
}
9 changes: 9 additions & 0 deletions snippets/snippets/todo/vgnq.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This will continue to work because
// the input todo is not modified
function toggleTodo(todo: Todo): Todo {
return {
id: todo.id,
text: todo.text,
done: !todo.done
}
}
16 changes: 16 additions & 0 deletions snippets/snippets/todo/wymp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const originalTodo = {
id: 1,
text: '…',
done: true
}

console.log('Before toggleTodo()…')
console.log(originalTodo)

const newTodo = toggleTodo(originalTodo)

console.log('After toggleTodo()…')
console.log('Original Todo:')
console.log(originalTodo)
console.log('New Todo:')
console.log(newTodo)
5 changes: 5 additions & 0 deletions snippets/snippets/todo/yhto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type Todo = {
readonly id: number
readonly text: string
readonly done: boolean
}
4 changes: 3 additions & 1 deletion src/components/ArticleList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const ArticleList = ({
const filteredArticleKeys = articleKeys.filter(
articleKey => articleKey !== ignoreArticleKey
)
return (
return filteredArticleKeys.length > 0 ? (
<>
<h4
css={css`
Expand Down Expand Up @@ -113,6 +113,8 @@ const ArticleList = ({
))}
</ul>
</>
) : (
<></>
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/CodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const CodeBlock = ({
resultVisible &&
resultError
? 'none'
: `3px solid ${colors('darkOrange')}`};
: `2px solid ${colors('darkOrange')}`};
text-decoration: ${shouldHighlightResult &&
resultVisible &&
resultError
Expand Down
1 change: 1 addition & 0 deletions src/components/ContentTags/Code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const Code = ({
css={[
css`
font-size: 0.95em;
font-style: normal;
word-break: break-word;
background: ${color ? colors(color) : colors('lightPink2')};
`
Expand Down
28 changes: 21 additions & 7 deletions src/components/TodoItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ const Todo = ({
<span
css={[
css`
margin: ${spaces('-0.25')} ${spaces(0.25)} ${spaces('-0.25')}
${spaces('-0.25')};
padding: ${spaces(0.25)};
margin: ${spaces('-0.25')} 0 ${spaces('-0.25')} ${spaces('-0.25')};
padding: ${spaces(0.25)} ${spaces(0.5)} ${spaces(0.25)}
${spaces(0.25)};

display: inline-block;
outline: none;
Expand All @@ -58,12 +58,26 @@ const Todo = ({
{done ? <Emoji type="check" /> : <TodoBlank hovered={todoHovered} />}
</span>
<span
css={
css={[
done &&
css`
color: ${colors('gray')};
`
css`
color: ${colors('gray')};
`,
!disabled &&
css`
cursor: pointer;
`
]}
onClick={() =>
disabled ? undefined : dispatch({ type: 'toggle', index })
}
onMouseOver={hoverOn}
onMouseOut={hoverOff}
onTouchStart={hoverOn}
onTouchEnd={hoverOff}
onTouchCancel={hoverOff}
onFocus={hoverOn}
onBlur={hoverOff}
>
{text}
</span>
Expand Down
2 changes: 1 addition & 1 deletion src/components/TodoWithData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const TodoWithData = ({
shouldHighlight(tokenIndex)
? {
background: `${colors('yellowHighlight')}`,
borderBottom: `3px solid ${colors('darkOrange')}`,
borderBottom: `2px solid ${colors('darkOrange')}`,
reset: true,
fontWeight: 'bold',
from: {
Expand Down
60 changes: 60 additions & 0 deletions src/lib/snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,12 @@ function toggleTodo(todo: Todo) {
// ...
}`

export const dqwb = `function toggleTodo(todo: Todo): Todo {
// Little Duckling’s refactoring
todo.done = !todo.done
return todo
}`

export const dxfc = `// Associated data. If we're using React, this
// would be the todo component’s props or state
[
Expand All @@ -513,6 +519,14 @@ console.log(\`{ id: 1, text: '…', done: false }\`)
console.log('Actual:')
console.log(result)`

export const njgr = `function toggleTodo(todo: Todo): Todo {
// Little Duckling’s refactoring is a
// bad refactoring because it modifies
// the original todo object
todo.done = !todo.done
return todo
}`

export const ntau = `function toggleTodo(todo: Todo): Todo {
// Little Duckling’s code from earlier:
// Missing the "id" property
Expand All @@ -522,6 +536,13 @@ export const ntau = `function toggleTodo(todo: Todo): Todo {
}
}`

export const qbgu = `// Returns a new todo object
// with the opposite boolean value
// for the "done" proprty.
function toggleTodo(todo) {
// ...
}`

export const reel = `function toggleTodo(todo) {
return {
text: todo.text,
Expand All @@ -534,6 +555,22 @@ export const tgvw = `const bar: Todo = {
done: true
}`

export const uxlb = `function toggleTodo(todo: Todo): Todo {
// Little Duckling’s refactoring
todo.done = !todo.done
return todo
}`

export const vgnq = `// This will continue to work because
// the input todo is not modified
function toggleTodo(todo: Todo): Todo {
return {
id: todo.id,
text: todo.text,
done: !todo.done
}
}`

export const vpco = `// Returns a new todo object with the opposite
// boolean value for the "done" proprty.
function toggleTodo(todo) {
Expand All @@ -546,6 +583,29 @@ function toggleTodo(todo) {
// { id: …, text: '…', done: true }
}`

export const wymp = `const originalTodo = {
id: 1,
text: '…',
done: true
}

console.log('Before toggleTodo()…')
console.log(originalTodo)

const newTodo = toggleTodo(originalTodo)

console.log('After toggleTodo()…')
console.log('Original Todo:')
console.log(originalTodo)
console.log('New Todo:')
console.log(newTodo)`

export const yhto = `type Todo = {
readonly id: number
readonly text: string
readonly done: boolean
}`

export const ywiv = `// The return value must match the Todo type
function toggleTodo(todo: Todo): Todo {
// ...
Expand Down
Loading