Skip to content
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
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
node_modules

# testing
coverage

# production
build

# misc
.DS_Store
npm-debug.log
921 changes: 920 additions & 1 deletion README.md

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="./src/favicon.ico">
<title>React App</title>
</head>
<body>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.

To begin the development, run `npm start` in this folder.
To create a production bundle, use `npm run build`.
-->
</body>
</html>
21 changes: 21 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "todo-list",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-scripts": "0.4.1"
},
"dependencies": {
"react": "^15.3.1",
"react-dom": "^15.3.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "./node_modules/react-scripts/config/eslint.js"
}
}
3 changes: 3 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.rm {
cursor: pointer;
}
69 changes: 69 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import React, { Component } from 'react';
import './App.css';

class NewItem extends Component {
render() {
const { addItem } = this.props;
return (
<div>
<form onSubmit={ (e) => {
e.preventDefault();
addItem(this.refs.new_item.value);
this.refs.new_item.value = '';
}}>
<input type='text' ref='new_item' />
<button type="submit">Add Item</button>
</form>
</div>
);
}
}

class ItemList extends Component {
render() {
const { items, removeItem } = this.props;
return (
<ul>
{ items.map((item, index) => <li className='rm' key={index} onClick={()=>removeItem(index)}>{item}</li>) }
</ul>
);
}
}

class Todo extends Component {
constructor(props) {
super(props);
this.state = {
items: ['Koupit maso', 'Vypit pivo']
};
}

render() {
const items = this.state.items;
return (
<div>
<h1>Todo List ({items.length})</h1>
<NewItem
addItem={ (item) => { if (item !== '') { this.setState({ items: items.concat([item]) }) } } }
/>
<ItemList
items={ items }
removeItem={ (i) => this.setState({ items: items.slice(0,i).concat(items.slice(i+1)) }) }
/>
</div>
);
}
}


class App extends Component {
render() {
return (
<div className="App">
<Todo />
</div>
);
}
}

export default App;
8 changes: 8 additions & 0 deletions src/App.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
});
Binary file added src/favicon.ico
Binary file not shown.
5 changes: 5 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
body {
margin: 10px;
padding: 10px;
font-family: sans-serif;
}
9 changes: 9 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';

ReactDOM.render(
<App />,
document.getElementById('root')
);
7 changes: 7 additions & 0 deletions src/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.