Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
e5ebecc
deleted Counter application
samardzicnenad Aug 4, 2017
bcd0639
created an action to add a todo
samardzicnenad Aug 4, 2017
445f930
handle initial state
samardzicnenad Aug 4, 2017
ea5157c
handle add todo
samardzicnenad Aug 4, 2017
ac623b6
TodoTextInput component
samardzicnenad Aug 4, 2017
712beaa
update value on change
samardzicnenad Aug 4, 2017
fb9f9d4
call onSave() on return key press
samardzicnenad Aug 4, 2017
26a947d
reset state on return key press if isNew
samardzicnenad Aug 4, 2017
d987923
call onSave() on blur if not isNew
samardzicnenad Aug 4, 2017
6982d1d
not call onSave() on blur if isNew
samardzicnenad Aug 4, 2017
3a5a9cd
Header component
samardzicnenad Aug 4, 2017
83a7140
have a title
samardzicnenad Aug 4, 2017
2e35b47
have a TodoTextInput field
samardzicnenad Aug 4, 2017
92fcc4a
call addTodo() if length of text is greater than 0
samardzicnenad Aug 4, 2017
d103115
have a header
samardzicnenad Aug 4, 2017
10222f9
tie it all together
samardzicnenad Aug 4, 2017
b8a5db0
be an li
samardzicnenad Aug 4, 2017
6bae7e3
have a label
samardzicnenad Aug 4, 2017
0e8a559
be a MainSection
samardzicnenad Aug 4, 2017
654dffd
include a list of todos
samardzicnenad Aug 4, 2017
d9e2ca2
have a MainSection
samardzicnenad Aug 4, 2017
02e3589
created an action to edit a todo
samardzicnenad Aug 5, 2017
8fa197e
handle edit todo
samardzicnenad Aug 5, 2017
48ba2af
switch to edit mode when label onDoubleClick is fired
samardzicnenad Aug 5, 2017
ddc550a
should call editTodo() when TodoTextInput onSave is called
samardzicnenad Aug 5, 2017
349f487
leave edit mode after TodoTextInput onSave
samardzicnenad Aug 5, 2017
0b83e62
added editTodo action to fix required prop warning
samardzicnenad Aug 5, 2017
1315559
created an action to delete a todo
samardzicnenad Aug 5, 2017
93a78ac
handle DELETE todo
samardzicnenad Aug 5, 2017
b0be342
have a delete button
samardzicnenad Aug 5, 2017
b0cbf98
call deleteTodo() when the delete button is clicked
samardzicnenad Aug 5, 2017
eb99ee5
call deleteTodo() when TodoTextInput onSave is called with no text
samardzicnenad Aug 5, 2017
69413e4
created an action to toggle a todo
samardzicnenad Aug 5, 2017
ce3d633
handle TOGGLE_COMPLETE_ONE todo
samardzicnenad Aug 5, 2017
ddf17df
have a toggle complete status checkbox
samardzicnenad Aug 5, 2017
eed5417
call toggleCompleteOneTodo() when the complete status checkbox is cha…
samardzicnenad Aug 5, 2017
7ac2bee
created an action to toggle all todos
samardzicnenad Aug 6, 2017
ac3d7e6
handle TOGGLE_COMPLETE_ALL todo
samardzicnenad Aug 6, 2017
9ca8ee2
have a toggle all complete status checkbox
samardzicnenad Aug 6, 2017
451ca9e
call toggleCompleteAllTodos() when the all complete status checkbox i…
samardzicnenad Aug 6, 2017
4d04628
Footer component
samardzicnenad Aug 6, 2017
f50e2b0
have a todo counter
samardzicnenad Aug 6, 2017
dfa9911
display 'No todos left' when active count is 0
samardzicnenad Aug 6, 2017
900dade
display '1 todo left' when active count is 1
samardzicnenad Aug 6, 2017
de71ef0
display '5 todos left' when active count is 5
samardzicnenad Aug 6, 2017
2673095
have a Footer component
samardzicnenad Aug 6, 2017
4a75ba1
completed radio-button filter
samardzicnenad Aug 6, 2017
d666ddb
show the filtered list of todos
samardzicnenad Aug 6, 2017
3449d58
created an action to delete all completed todos
samardzicnenad Aug 6, 2017
a1e3ac2
handle DELETE_COMPLETED todo
samardzicnenad Aug 6, 2017
2c2b1a0
have a delete completed button
samardzicnenad Aug 6, 2017
1a47fd9
delete completed button renders as expected
samardzicnenad Aug 6, 2017
ccf203c
call deleteCompletedTodos() when the delete completed button is clicked
samardzicnenad Aug 6, 2017
cf02c7d
additional code cleanup - already included in tutorial
samardzicnenad Aug 6, 2017
ccbd9f8
added Radium and decorators
samardzicnenad Aug 10, 2017
2b39483
added styling for the page
samardzicnenad Aug 10, 2017
213b81e
TodoApp styling applied
samardzicnenad Aug 11, 2017
ee82231
Header header styling applied
samardzicnenad Aug 11, 2017
aff019b
Header h1 styling applied
samardzicnenad Aug 11, 2017
889d71b
Header checkbox styling applied
samardzicnenad Aug 11, 2017
c62be65
have a toggle all complete status span
samardzicnenad Aug 11, 2017
580a7ce
Header span styling applied
samardzicnenad Aug 11, 2017
90baff5
TodoTextInput new styling applied
samardzicnenad Aug 11, 2017
e4ecefa
TodoTextInput edit styling applied
samardzicnenad Aug 11, 2017
43c5431
MainSection structure updated
samardzicnenad Aug 11, 2017
cb79eb8
MainSection styling decoration applied
samardzicnenad Aug 11, 2017
3bc73ef
MainSection section styling applied
samardzicnenad Aug 11, 2017
85c7aba
MainSection ul styling applied
samardzicnenad Aug 11, 2017
942d2d6
MainSection radiobuttons styling applied
samardzicnenad Aug 11, 2017
bf937b8
TodoItem markup updated
samardzicnenad Aug 16, 2017
dc984e6
li styling applied
samardzicnenad Aug 16, 2017
180cecc
ButtonChecked styling applied
samardzicnenad Aug 16, 2017
c9dae87
ButtonUnchecked styling applied
samardzicnenad Aug 16, 2017
c68489c
label not completed styling applied
samardzicnenad Aug 16, 2017
01b50ce
label completed styling applied
samardzicnenad Aug 16, 2017
fda1959
delete div styling applied
samardzicnenad Aug 16, 2017
e677b09
initially hide delete div
samardzicnenad Aug 16, 2017
6c432c3
display div only on hover
samardzicnenad Aug 16, 2017
126c9b6
Footer footer styling applied
samardzicnenad Aug 16, 2017
6d5daa7
number of non completed todos in bold
samardzicnenad Aug 16, 2017
e59e1a9
delete button styling applied
samardzicnenad Aug 16, 2017
ed72e81
delete button hover styling applied
samardzicnenad Aug 16, 2017
9467495
NS: Additional code cleanup
samardzicnenad Aug 18, 2017
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: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"presets": ["es2015", "stage-0", "react"]
"presets": ["es2015", "stage-0", "react"],
"plugins": ["transform-decorators-legacy"]
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"dependencies": {
"express": "^4.15.4",
"immutable": "^3.8.1",
"radium": "^0.19.4",
"react": "^15.6.1",
"react-redux": "^5.0.5",
"redux": "^3.7.2",
Expand All @@ -45,6 +46,8 @@
"babel-core": "^6.25.0",
"babel-eslint": "^7.2.3",
"babel-loader": "^7.1.1",
"babel-plugin-transform-decorators": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
Expand Down
4 changes: 2 additions & 2 deletions src/containers/Root.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import React, {Component} from 'react'
import {Provider} from 'react-redux'
import {CounterApp} from '../counter'
import {TodoApp} from '../todomvc'
import PropTypes from '../PropTypes'
import DevTools from './DevTools'

Expand All @@ -12,7 +12,7 @@ class Root extends Component {
return (
<Provider store={store}>
<div>
<CounterApp/>
<TodoApp/>
<DevTools/>
</div>
</Provider>
Expand Down
4 changes: 2 additions & 2 deletions src/containers/Root.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import React, {Component} from 'react'
import {Provider} from 'react-redux'
import {CounterApp} from '../counter'
import {TodoApp} from '../todomvc'
import PropTypes from '../PropTypes'

class Root extends Component {
render() {
const {store} = this.props;
return (
<Provider store={store}>
<CounterApp/>
<TodoApp/>
</Provider>
)
}
Expand Down
4 changes: 0 additions & 4 deletions src/counter/ActionTypes.js

This file was deleted.

15 changes: 0 additions & 15 deletions src/counter/actions.js

This file was deleted.

55 changes: 0 additions & 55 deletions src/counter/components/Counter.js

This file was deleted.

30 changes: 0 additions & 30 deletions src/counter/components/CounterApp.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/counter/components/index.js

This file was deleted.

7 changes: 0 additions & 7 deletions src/counter/index.js

This file was deleted.

15 changes: 0 additions & 15 deletions src/counter/reducer.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/reducers.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

import {combineReducers} from 'redux'
import counter from './counter'
import todomvc from './todomvc'

const rootReducer = combineReducers({
counter: counter.reducer
todos: todomvc.reducer
});

export default rootReducer
8 changes: 8 additions & 0 deletions src/todomvc/ActionTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

export const ADD = 'todomvc/ADD';
export const EDIT = 'todomvc/EDIT';
export const DELETE = 'todomvc/DELETE';
export const TOGGLE_COMPLETE_ONE = 'todomvc/TOGGLE_COMPLETE_ONE';
export const TOGGLE_COMPLETE_ALL = 'todomvc/TOGGLE_COMPLETE_ALL';
export const DELETE_COMPLETED = 'todomvc/DELETE_COMPLETED';
27 changes: 27 additions & 0 deletions src/todomvc/actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

import * as types from './ActionTypes'

export function addTodo(text) {
return {type: types.ADD, description: text, completed: false}
}

export function editTodo(id, text) {
return {type: types.EDIT, id: id, description: text}
}

export function deleteTodo(id) {
return {type: types.DELETE, id: id}
}

export function toggleCompleteOneTodo(id) {
return {type: types.TOGGLE_COMPLETE_ONE, id: id}
}

export function toggleCompleteAllTodos(all_completed = true) {
return {type: types.TOGGLE_COMPLETE_ALL, all_completed: all_completed}
}

export function deleteCompletedTodos() {
return {type: types.DELETE_COMPLETED}
}
69 changes: 69 additions & 0 deletions src/todomvc/components/Footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
'use strict';

import React, {Component} from 'react'
import PropTypes from 'prop-types'
import Radium from 'radium'

@Radium
export default class Footer extends Component {
static propTypes = {
todos: PropTypes.object,
deleteCompletedTodos: PropTypes.func.isRequired
};

styles = {
footer: {
color: '#777',
padding: '10px 15px',
height: 20,
borderTop: '1px solid #e6e6e6'
},

deleteCompleted: {
position: 'relative',
float: 'right',
marginTop: 2,
border: 0,
color: 'rgba(175, 47, 47, 0.75)',
background: 'none',
textDecoration: 'none',
fontSize: '100%',
cursor: 'pointer',
WebkitAppearance: 'none',
WebkitFontSmoothing: 'antialiased',
MozOsxFontSmoothing: 'grayscale',
':hover': {
fontStyle: 'italic',
fontWeight: 'bold',
color: 'indianred'
},
}
};

static hasCompleted(todos) {
if (typeof todos === "undefined") return false;
else return todos.filter(todo => todo.get('completed') === true).count() > 0;
}

static countNotCompleted(todos) {
if (typeof todos === "undefined") return '';
else if (todos.filter(todo => todo.get('completed') !== true).count() === 0) return 'No todos left';
else if (todos.filter(todo => todo.get('completed') !== true).count() === 1) return '1 todo left';
else return `${todos.filter(todo => todo.get('completed') !== true).count()} todos left`
}

render() {
const todos = this.props.todos;
const deleteCompletedTodos = this.props.deleteCompletedTodos;

return (
<footer style={this.styles.footer}>
<label>
The number of todos not completed: <strong>{Footer.countNotCompleted(todos)}</strong>
</label>
{Footer.hasCompleted(todos) &&
<button style={this.styles.deleteCompleted} onClick={() => deleteCompletedTodos()}>delete completed</button>}
</footer>
)
}
}
Loading