Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #285 from huodoushigemi/main
Browse files Browse the repository at this point in the history
docs: The code for tutorial/stores_nested_reactivity is consistent with en
  • Loading branch information
edemaine authored Feb 4, 2024
2 parents 01115f1 + 0e19273 commit c6277aa
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 15 deletions.
3 changes: 1 addition & 2 deletions langs/de/tutorials/stores_nested_reactivity/lesson.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ Jetzt können wir den Erledigungszustand aktualisieren, indem wir `setCompleted`

```js
const toggleTodo = (id) => {
const index = todos().findIndex((t) => t.id === id);
const todo = todos()[index];
const todo = todos().find((t) => t.id === id);
if (todo) todo.setCompleted(!todo.completed())
}
```
Expand Down
2 changes: 1 addition & 1 deletion langs/de/tutorials/stores_nested_reactivity/solved.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"files": [
{
"name": "main",
"content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const index = todos().findIndex((t) => t.id === id);\n const todo = todos()[index];\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n <div>\n <input ref={input} />\n <button\n onClick={(e) => {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n </button>\n </div>\n <For each={todos()}>\n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return <div>\n <input\n type=\"checkbox\"\n checked={todo.completed()}\n onchange={[toggleTodo, id]}\n />\n <span\n style={{ \"text-decoration\": todo.completed() ? \"line-through\" : \"none\"}}\n >{text}</span>\n </div>\n }}\n </For>\n </>\n );\n};\n\nrender(App, document.getElementById(\"app\"));\n"
"content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const todo = todos().find((t) => t.id === id);\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n <div>\n <input ref={input} />\n <button\n onClick={(e) => {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n </button>\n </div>\n <For each={todos()}>\n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return <div>\n <input\n type=\"checkbox\"\n checked={todo.completed()}\n onchange={[toggleTodo, id]}\n />\n <span\n style={{ \"text-decoration\": todo.completed() ? \"line-through\" : \"none\"}}\n >{text}</span>\n </div>\n }}\n </For>\n </>\n );\n};\n\nrender(App, document.getElementById(\"app\"));\n"
}
]
}
3 changes: 1 addition & 2 deletions langs/it/tutorials/stores_nested_reactivity/lesson.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ Now we can update the completion state by calling `setCompleted` without any add

```js
const toggleTodo = (id) => {
const index = todos().findIndex((t) => t.id === id);
const todo = todos()[index];
const todo = todos().find((t) => t.id === id);
if (todo) todo.setCompleted(!todo.completed())
}
```
Expand Down
2 changes: 1 addition & 1 deletion langs/it/tutorials/stores_nested_reactivity/solved.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"files": [
{
"name": "main",
"content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const index = todos().findIndex((t) => t.id === id);\n const todo = todos()[index];\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n <div>\n <input ref={input} />\n <button\n onClick={(e) => {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n </button>\n </div>\n <For each={todos()}>\n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return <div>\n <input\n type=\"checkbox\"\n checked={todo.completed()}\n onchange={[toggleTodo, id]}\n />\n <span\n style={{ \"text-decoration\": todo.completed() ? \"line-through\" : \"none\"}}\n >{text}</span>\n </div>\n }}\n </For>\n </>\n );\n};\n\nrender(App, document.getElementById(\"app\"));\n"
"content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const todo = todos().find((t) => t.id === id);\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n <div>\n <input ref={input} />\n <button\n onClick={(e) => {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n </button>\n </div>\n <For each={todos()}>\n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return <div>\n <input\n type=\"checkbox\"\n checked={todo.completed()}\n onchange={[toggleTodo, id]}\n />\n <span\n style={{ \"text-decoration\": todo.completed() ? \"line-through\" : \"none\"}}\n >{text}</span>\n </div>\n }}\n </For>\n </>\n );\n};\n\nrender(App, document.getElementById(\"app\"));\n"
}
]
}
3 changes: 1 addition & 2 deletions langs/ja/tutorials/stores_nested_reactivity/lesson.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ const addTodo = (text) => {

```js
const toggleTodo = (id) => {
const index = todos().findIndex((t) => t.id === id);
const todo = todos()[index];
const todo = todos().find((t) => t.id === id);
if (todo) todo.setCompleted(!todo.completed())
}
```
Expand Down
2 changes: 1 addition & 1 deletion langs/ja/tutorials/stores_nested_reactivity/solved.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"files": [
{
"name": "main",
"content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const index = todos().findIndex((t) => t.id === id);\n const todo = todos()[index];\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n <div>\n <input ref={input} />\n <button\n onClick={(e) => {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n </button>\n </div>\n <For each={todos()}>\n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return <div>\n <input\n type=\"checkbox\"\n checked={todo.completed()}\n onchange={[toggleTodo, id]}\n />\n <span\n style={{ \"text-decoration\": todo.completed() ? \"line-through\" : \"none\"}}\n >{text}</span>\n </div>\n }}\n </For>\n </>\n );\n};\n\nrender(App, document.getElementById(\"app\"));\n"
"content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const todo = todos().find((t) => t.id === id);\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n <div>\n <input ref={input} />\n <button\n onClick={(e) => {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n </button>\n </div>\n <For each={todos()}>\n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return <div>\n <input\n type=\"checkbox\"\n checked={todo.completed()}\n onchange={[toggleTodo, id]}\n />\n <span\n style={{ \"text-decoration\": todo.completed() ? \"line-through\" : \"none\"}}\n >{text}</span>\n </div>\n }}\n </For>\n </>\n );\n};\n\nrender(App, document.getElementById(\"app\"));\n"
}
]
}
3 changes: 1 addition & 2 deletions langs/ru/tutorials/stores_nested_reactivity/lesson.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ const addTodo = (text) => {

```js
const toggleTodo = (id) => {
const index = todos().findIndex((t) => t.id === id);
const todo = todos()[index];
const todo = todos().find((t) => t.id === id);
if (todo) todo.setCompleted(!todo.completed())
}
```
Expand Down
2 changes: 1 addition & 1 deletion langs/ru/tutorials/stores_nested_reactivity/solved.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"files": [
{
"name": "main",
"content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const index = todos().findIndex((t) => t.id === id);\n const todo = todos()[index];\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n <div>\n <input ref={input} />\n <button\n onClick={(e) => {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n </button>\n </div>\n <For each={todos()}>\n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return <div>\n <input\n type=\"checkbox\"\n checked={todo.completed()}\n onchange={[toggleTodo, id]}\n />\n <span\n style={{ \"text-decoration\": todo.completed() ? \"line-through\" : \"none\"}}\n >{text}</span>\n </div>\n }}\n </For>\n </>\n );\n};\n\nrender(App, document.getElementById(\"app\"));\n"
"content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const todo = todos().find((t) => t.id === id);\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n <div>\n <input ref={input} />\n <button\n onClick={(e) => {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n </button>\n </div>\n <For each={todos()}>\n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return <div>\n <input\n type=\"checkbox\"\n checked={todo.completed()}\n onchange={[toggleTodo, id]}\n />\n <span\n style={{ \"text-decoration\": todo.completed() ? \"line-through\" : \"none\"}}\n >{text}</span>\n </div>\n }}\n </For>\n </>\n );\n};\n\nrender(App, document.getElementById(\"app\"));\n"
}
]
}
3 changes: 1 addition & 2 deletions langs/zh-cn/tutorials/stores_nested_reactivity/lesson.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ const addTodo = (text) => {

```js
const toggleTodo = (id) => {
const index = todos().findIndex((t) => t.id === id);
const todo = todos()[index];
const todo = todos().find((t) => t.id === id);
if (todo) todo.setCompleted(!todo.completed())
}
```
Expand Down
2 changes: 1 addition & 1 deletion langs/zh-cn/tutorials/stores_nested_reactivity/solved.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"files": [
{
"name": "main",
"content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const index = todos().findIndex((t) => t.id === id);\n const todo = todos()[index];\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n <div>\n <input ref={input} />\n <button\n onClick={(e) => {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n </button>\n </div>\n <For each={todos()}>\n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return <div>\n <input\n type=\"checkbox\"\n checked={todo.completed()}\n onchange={[toggleTodo, id]}\n />\n <span\n style={{ \"text-decoration\": todo.completed() ? \"line-through\" : \"none\"}}\n >{text}</span>\n </div>\n }}\n </For>\n </>\n );\n};\n\nrender(App, document.getElementById(\"app\"));\n"
"content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const todo = todos().find((t) => t.id === id);\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n <div>\n <input ref={input} />\n <button\n onClick={(e) => {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n </button>\n </div>\n <For each={todos()}>\n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return <div>\n <input\n type=\"checkbox\"\n checked={todo.completed()}\n onchange={[toggleTodo, id]}\n />\n <span\n style={{ \"text-decoration\": todo.completed() ? \"line-through\" : \"none\"}}\n >{text}</span>\n </div>\n }}\n </For>\n </>\n );\n};\n\nrender(App, document.getElementById(\"app\"));\n"
}
]
}

0 comments on commit c6277aa

Please sign in to comment.