Skip to content
This repository was archived by the owner on Nov 18, 2024. It is now read-only.

Commit fc3f3f2

Browse files
committed
update
1 parent e3eeb88 commit fc3f3f2

File tree

14 files changed

+199
-309
lines changed

14 files changed

+199
-309
lines changed

public/index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
56
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6-
<meta name="theme-color" content="#000000">
7+
<meta name="theme-color" content="#A082D1">
8+
<meta name="author" content="Yingray Lu">
9+
<meta name="keywords" content="react,redux,sass,create-react-app">
710
<!--
811
manifest.json provides metadata used when your web app is added to the
912
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
1013
-->
1114
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
1215
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
13-
<title>React Redux Project Starter</title>
16+
<title>React Redux Sass Project Starter</title>
1417
</head>
1518
<body>
1619
<noscript>
@@ -26,6 +29,5 @@
2629

2730
ga('create', 'UA-100740925-2', 'auto');
2831
ga('send', 'pageview');
29-
3032
</script>
3133
</html>

src/apis/apis.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/apis/fetchCreators.js

Lines changed: 0 additions & 67 deletions
This file was deleted.

src/components/Link.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
import React from 'react'
22

33
const Link = ({ active, children, onClick }) => {
4-
if (active) {
5-
return <span>{children}</span>
6-
}
4+
if (active) {
5+
return (
6+
<span>
7+
{children}
8+
</span>
9+
)
10+
}
711

8-
return (
9-
<a href="/"
10-
onClick={e => {
11-
e.preventDefault()
12-
onClick()
13-
}}
14-
>
15-
{children}
16-
</a>
17-
)
12+
return (
13+
<a
14+
href="/"
15+
onClick={e => {
16+
e.preventDefault()
17+
onClick()
18+
}}
19+
>
20+
{children}
21+
</a>
22+
)
1823
}
1924

20-
export default Link
25+
export default Link

src/components/Navigation.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
import React from 'react'
22
import { Link } from 'react-router'
33

4-
const Navigation = ({ className, buttonClassName }) => (
5-
<nav className={className}>
6-
<Link className={buttonClassName} to="/">Home</Link>
7-
<Link className={buttonClassName} to="todo">Todo</Link>
8-
<Link className={buttonClassName} to="weather">Weather</Link>
9-
</nav>
10-
)
4+
const Navigation = ({ className, buttonClassName }) =>
5+
<nav className={className}>
6+
<Link className={buttonClassName} to="/">
7+
Home
8+
</Link>
9+
<Link className={buttonClassName} to="todo">
10+
Todo
11+
</Link>
12+
<Link className={buttonClassName} to="weather">
13+
Weather
14+
</Link>
15+
</nav>
1116

1217
Navigation.defaultProps = {
13-
className: '',
14-
buttonClassName: 'c-button'
18+
className: '',
19+
buttonClassName: 'c-button'
1520
}
1621

1722
export default Navigation

src/components/TodoFooter.js

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
import React from 'react'
22
import FilterLink from '../containers/FilterLink'
33

4-
const TodoFooter = () => (
5-
<p>
6-
Show:
7-
{" "}
8-
<FilterLink filter="SHOW_ALL">
9-
All
10-
</FilterLink>
11-
{", "}
12-
<FilterLink filter="SHOW_ACTIVE">
13-
Active
14-
</FilterLink>
15-
{", "}
16-
<FilterLink filter="SHOW_COMPLETED">
17-
Completed
18-
</FilterLink>
19-
</p>
20-
)
4+
const TodoFooter = () =>
5+
<p>
6+
Show: <FilterLink filter="SHOW_ALL">All</FilterLink>
7+
{', '}
8+
<FilterLink filter="SHOW_ACTIVE">Active</FilterLink>
9+
{', '}
10+
<FilterLink filter="SHOW_COMPLETED">Completed</FilterLink>
11+
</p>
2112

22-
export default TodoFooter
13+
export default TodoFooter

src/constants/ServerConfig.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/containers/FilterLink.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,19 @@ import { setVisibilityFilter } from '../actions/todoActions'
33
import Link from '../components/Link'
44

55
const mapStateToProps = (state, ownProps) => {
6-
return {
7-
active: ownProps.filter === state.visibilityFilter
8-
}
6+
return {
7+
active: ownProps.filter === state.visibilityFilter
8+
}
99
}
1010

1111
const mapDispatchToProps = (dispatch, ownProps) => {
12-
return {
13-
onClick: () => {
14-
dispatch(setVisibilityFilter(ownProps.filter))
15-
}
16-
}
12+
return {
13+
onClick: () => {
14+
dispatch(setVisibilityFilter(ownProps.filter))
15+
}
16+
}
1717
}
1818

19-
const FilterLink = connect(
20-
mapStateToProps,
21-
mapDispatchToProps
22-
)(Link)
19+
const FilterLink = connect(mapStateToProps, mapDispatchToProps)(Link)
2320

2421
export default FilterLink

src/containers/VisibleTodoList.js

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,32 @@ import { toggleTodo } from '../actions/todoActions'
33
import TodoList from '../components/TodoList'
44

55
const getVisibleTodos = (todos, filter) => {
6-
switch (filter) {
7-
case 'SHOW_ALL':
8-
return todos
9-
case 'SHOW_COMPLETED':
10-
return todos.filter(t => t.completed)
11-
case 'SHOW_ACTIVE':
12-
return todos.filter(t => !t.completed)
13-
default:
14-
break;
15-
}
6+
switch (filter) {
7+
case 'SHOW_ALL':
8+
return todos
9+
case 'SHOW_COMPLETED':
10+
return todos.filter(t => t.completed)
11+
case 'SHOW_ACTIVE':
12+
return todos.filter(t => !t.completed)
13+
default:
14+
break
15+
}
1616
}
1717

18-
const mapStateToProps = (state) => {
19-
return {
20-
todos: getVisibleTodos(state.todos, state.visibilityFilter)
21-
}
18+
const mapStateToProps = state => {
19+
return {
20+
todos: getVisibleTodos(state.todos, state.visibilityFilter)
21+
}
2222
}
2323

24-
const mapDispatchToProps = (dispatch) => {
25-
return {
26-
onTodoClick: (id) => {
27-
dispatch(toggleTodo(id))
28-
}
29-
}
24+
const mapDispatchToProps = dispatch => {
25+
return {
26+
onTodoClick: id => {
27+
dispatch(toggleTodo(id))
28+
}
29+
}
3030
}
3131

32-
const VisibleTodoList = connect(
33-
mapStateToProps,
34-
mapDispatchToProps
35-
)(TodoList)
32+
const VisibleTodoList = connect(mapStateToProps, mapDispatchToProps)(TodoList)
3633

37-
export default VisibleTodoList
34+
export default VisibleTodoList

src/reducers/todos.js

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
11
const todo = (state = {}, action) => {
2-
switch (action.type) {
3-
case 'ADD_TODO':
4-
return {
5-
id: action.id,
6-
text: action.text,
7-
completed: false
8-
}
9-
case 'TOGGLE_TODO':
10-
if (state.id !== action.id) {
11-
return state
12-
}
2+
switch (action.type) {
3+
case 'ADD_TODO':
4+
return {
5+
id: action.id,
6+
text: action.text,
7+
completed: false
8+
}
9+
case 'TOGGLE_TODO':
10+
if (state.id !== action.id) {
11+
return state
12+
}
1313

14-
return Object.assign({}, state, {
15-
completed: !state.completed
16-
})
14+
return Object.assign({}, state, {
15+
completed: !state.completed
16+
})
1717

18-
default:
19-
return state
20-
}
18+
default:
19+
return state
20+
}
2121
}
2222

2323
const todos = (state = [], action) => {
24-
switch (action.type) {
25-
case 'ADD_TODO':
26-
return [
27-
...state,
28-
todo(undefined, action)
29-
]
30-
case 'TOGGLE_TODO':
31-
return state.map(t =>
32-
todo(t, action)
33-
)
34-
default:
35-
return state
36-
}
24+
switch (action.type) {
25+
case 'ADD_TODO':
26+
return [...state, todo(undefined, action)]
27+
case 'TOGGLE_TODO':
28+
return state.map(t => todo(t, action))
29+
default:
30+
return state
31+
}
3732
}
3833

39-
export default todos
34+
export default todos

0 commit comments

Comments
 (0)