Skip to content

Introduce new components and data #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: step/1-HelloWorld
Choose a base branch
from
Open
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
3 changes: 0 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
<title>MontpellierJS - ToDo List!</title>
</head>
<body>

<div id="app"></div>

<script src="build/bundle.js"></script>

</body>
</html>
12 changes: 12 additions & 0 deletions src/components/Todo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react'

export default function Todo(props){
return (
<li style={{
textDecoration: props.completed ? 'line-through' : 'none',
cursor: props.completed ? 'default' : 'pointer'
}}>
{props.text}
</li>
)
}
4 changes: 3 additions & 1 deletion src/components/TodoApp.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from 'react'

import TodoList from './TodoList'

export default function TodoApp(props) {
return (
<div className="todoApp">
Todo : Build The App
<TodoList data={props.data}/>
</div>
)
}
15 changes: 15 additions & 0 deletions src/components/TodoList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react'

import Todo from './Todo'

export default function TodoList(props) {
return (
<div className="TodoList">
<ul>
{props.data.map(function(todo) {
return <Todo key={todo.id} completed={todo.completed} text={todo.text} />
})}
</ul>
</div>
)
}
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ import React from 'react'
import { render } from 'react-dom'
import TodoApp from './components/TodoApp'

render((<TodoApp/>),document.getElementById('app'))
var data = [
{id: 1, text: "Do The App", completed: 0},
{id: 2, text: "Add data", completed: 1},
]

render((<TodoApp data={data}/>), document.getElementById('app'))