-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated most of the components and containers & updated reducers and …
…actions & added redux-dev-tools
- Loading branch information
Chong Guo
committed
Feb 27, 2017
1 parent
b1875ad
commit bcafed4
Showing
47 changed files
with
1,106 additions
and
1,065 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,25 @@ | ||
import React from 'react'; | ||
import { Provider } from 'react-redux'; | ||
import { Router, browserHistory } from 'react-router'; | ||
import { routerReducer, syncHistoryWithStore } from 'react-router-redux'; | ||
import { combineReducers, createStore } from 'redux'; | ||
import { Router } from 'react-router'; | ||
|
||
import DevTools from 'containers/DevTools'; | ||
import routes from 'router'; | ||
import { isProduction } from 'utils'; | ||
|
||
import 'image/favicon.ico'; | ||
import 'js/bin/materialize.min'; | ||
import 'sass/index.scss'; | ||
|
||
// Add the reducer to your store on the `routing` key | ||
const store = createStore( | ||
combineReducers({ | ||
// ...reducers, | ||
routing: routerReducer, | ||
}), | ||
); | ||
|
||
// Create an enhanced history that syncs navigation events with the store | ||
const history = syncHistoryWithStore(browserHistory, store); | ||
|
||
// Set the store, history and routers | ||
export default () => { | ||
return ( | ||
<Provider store={store}> | ||
<Router history={history} routes={routes}/> | ||
</Provider> | ||
); | ||
}; | ||
export default class App extends React.Component<any, any> { | ||
public render() { | ||
return ( | ||
<Provider store={this.props.store}> | ||
<div> | ||
<Router history={this.props.history} routes={routes}/> | ||
{!isProduction && <DevTools />} | ||
</div> | ||
</Provider> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from 'actions/todoList'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ADD_TODO, SET_VISIBILITY_FILTER, TOGGLE_TODO } from 'constants/actionTypes'; | ||
import { IActionAddTodo, IActionSetVisibilityFilter, IActionToggleTodo, IVisibilityFilterOptions } from 'types'; | ||
import { v1 } from 'uuid'; | ||
|
||
export const addTodo = (text: string): IActionAddTodo => { | ||
return { | ||
type: ADD_TODO, | ||
id: v1(), | ||
text, | ||
completed: false, | ||
}; | ||
}; | ||
|
||
export const toggleTodo = (id: string): IActionToggleTodo => { | ||
return { | ||
type: TOGGLE_TODO, | ||
id, | ||
}; | ||
}; | ||
|
||
export const setVisibilityFilter = (filter: IVisibilityFilterOptions): IActionSetVisibilityFilter => { | ||
return { | ||
type: SET_VISIBILITY_FILTER, | ||
filter, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
|
||
import { ITodoModel } from 'types'; | ||
|
||
interface ITodoProps extends ITodoModel { | ||
onClick: () => void; | ||
} | ||
|
||
interface ITodoState {} | ||
|
||
class Todo extends React.Component<ITodoProps, ITodoState> { | ||
public render() { | ||
return ( | ||
<li onClick={this.props.onClick} style={{ textDecoration: this.props.completed ? 'line-through' : 'none' }}> | ||
{this.props.text} | ||
</li> | ||
); | ||
} | ||
} | ||
|
||
export default Todo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
|
||
import TodoFooter from 'components/TodoFooter'; | ||
import AddTodo from 'containers/AddTodo'; | ||
import VisibleTodoList from 'containers/VisibleTodoList'; | ||
|
||
interface ITodoAppProps {} | ||
|
||
interface ITodoAppState {} | ||
|
||
class TodoApp extends React.Component<ITodoAppProps, ITodoAppState> { | ||
public render() { | ||
return ( | ||
<div> | ||
<AddTodo /> | ||
<VisibleTodoList /> | ||
<TodoFooter /> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default TodoApp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
|
||
import FilterLink from 'containers/FilterLink'; | ||
|
||
interface ITodoFooterProps {} | ||
|
||
interface ITodoFooterState {} | ||
|
||
class TodoFooter extends React.Component<ITodoFooterProps, ITodoFooterState> { | ||
public render() { | ||
return ( | ||
<p> | ||
Show: | ||
{' '} | ||
<FilterLink filter="SHOW_ALL"> | ||
All | ||
</FilterLink> | ||
{', '} | ||
<FilterLink filter="SHOW_ACTIVE"> | ||
Active | ||
</FilterLink> | ||
{', '} | ||
<FilterLink filter="SHOW_COMPLETED"> | ||
Completed | ||
</FilterLink> | ||
</p> | ||
); | ||
} | ||
} | ||
|
||
export default TodoFooter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from 'react'; | ||
|
||
export interface ITodoInputStateProps {} | ||
|
||
export interface ITodoInputDispatchProps { | ||
onSubmit: (inputValue: string) => void; | ||
} | ||
|
||
type ITodoInputProps = ITodoInputStateProps & ITodoInputDispatchProps; | ||
|
||
interface ITodoInputState {} | ||
|
||
let input: HTMLInputElement; | ||
|
||
class TodoInput extends React.Component<ITodoInputProps, ITodoInputState> { | ||
public onSubmit = (e: React.FormEvent<HTMLFormElement>): void => { | ||
e.preventDefault(); | ||
if (!input.value.trim()) { | ||
return; | ||
} | ||
this.props.onSubmit(input.value); | ||
input.value = ''; | ||
} | ||
|
||
public setInput = (node: HTMLInputElement): void => { | ||
input = node; | ||
} | ||
|
||
public render() { | ||
return ( | ||
<div> | ||
<form onSubmit={this.onSubmit}> | ||
<input ref={this.setInput}/> | ||
<button type="submit"> | ||
Add Todo | ||
</button> | ||
</form> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default TodoInput; |
Oops, something went wrong.