-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
21,217 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
{ | ||
"name": "mkd-app", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"react": "^16.3.0", | ||
"react-dom": "^16.3.0", | ||
"react-redux": "^5.0.7", | ||
"react-router-dom": "^4.2.2", | ||
"react-scripts": "1.1.2", | ||
"redux": "^3.7.2", | ||
"redux-thunk": "^2.2.0", | ||
"uuid": "^3.2.1" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test --env=jsdom", | ||
"eject": "react-scripts eject" | ||
} | ||
} |
Binary file not shown.
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,40 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<meta name="theme-color" content="#000000"> | ||
<!-- | ||
manifest.json provides metadata used when your web app is added to the | ||
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/ | ||
--> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json"> | ||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> | ||
<!-- | ||
Notice the use of %PUBLIC_URL% in the tags above. | ||
It will be replaced with the URL of the `public` folder during the build. | ||
Only files inside the `public` folder can be referenced from the HTML. | ||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
--> | ||
<title>React App</title> | ||
</head> | ||
<body> | ||
<noscript> | ||
You need to enable JavaScript to run this app. | ||
</noscript> | ||
<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` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--> | ||
</body> | ||
</html> |
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,15 @@ | ||
{ | ||
"short_name": "React App", | ||
"name": "Create React App Sample", | ||
"icons": [ | ||
{ | ||
"src": "favicon.ico", | ||
"sizes": "64x64 32x32 24x24 16x16", | ||
"type": "image/x-icon" | ||
} | ||
], | ||
"start_url": "./index.html", | ||
"display": "standalone", | ||
"theme_color": "#000000", | ||
"background_color": "#ffffff" | ||
} |
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,13 @@ | ||
/** | ||
* @file actions | ||
* @date 2018/4/4 | ||
*/ | ||
|
||
import uuid from 'uuid/v4'; | ||
|
||
export function addMkd() { | ||
return { | ||
type: 'ADD_MKD', | ||
id: uuid() | ||
}; | ||
} |
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,68 @@ | ||
/** | ||
* @file home.js | ||
* @date 2018/4/4 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
|
||
// component | ||
import ItemList from './listItem'; | ||
|
||
// action | ||
import { addMkd } from '../../actions'; | ||
|
||
class Home extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
list: [] | ||
} | ||
} | ||
|
||
componentDidMount() { | ||
this.updatedState(); | ||
} | ||
|
||
updatedState() { | ||
this.props.handleAddClick(); | ||
this.setState({ | ||
list: this.props.list | ||
}); | ||
} | ||
|
||
getListDom(list) { | ||
let dom = list && list.map((item, key) => { | ||
return <ItemList data={item} key={key} /> | ||
}); | ||
|
||
return dom; | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
{this.getListDom(this.state.list)} | ||
<button onClick={() => this.updatedState()}>添加</button> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
let Component = connect( | ||
state => { | ||
return { | ||
list: state.mkds | ||
} | ||
}, | ||
dispatch => { | ||
return { | ||
handleAddClick: function() { | ||
dispatch(addMkd()); | ||
} | ||
} | ||
} | ||
)(Home); | ||
|
||
export default Component; |
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,24 @@ | ||
/** | ||
* @file listItem | ||
* @date 2018/4/4 | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import styles from './style.less'; | ||
|
||
export default class ListItem extends React.Component { | ||
render() { | ||
const {data = {}, ...other} = this.props; | ||
const {title} = data; | ||
|
||
return ( | ||
<div | ||
className='list-item' | ||
{...other} | ||
> | ||
<p>{title}</p> | ||
</div> | ||
) | ||
}; | ||
} |
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,7 @@ | ||
.list-item { | ||
display: inline-block; | ||
width: 100px; | ||
height: 200px; | ||
background-color: #F5DEB3; | ||
box-shadow: 0 0 0 10px brown; | ||
} |
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,15 @@ | ||
import React from 'react'; | ||
import { BrowserRouter, Route } from 'react-router-dom'; | ||
|
||
// component | ||
import Home from './home'; | ||
|
||
export default class App extends React.Component { | ||
render() { | ||
return ( | ||
<BrowserRouter> | ||
<Route excat path='/' component={Home} /> | ||
</BrowserRouter> | ||
); | ||
} | ||
} |
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 @@ | ||
/** | ||
* @file index.js | ||
* @date 2018/4/4 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { render } from 'react-dom'; | ||
import { applyMiddleware, createStore } from 'redux'; | ||
import { Provider } from 'react-redux'; | ||
import thunk from 'redux-thunk'; | ||
import reducer from './reducers'; | ||
import App from './components'; | ||
|
||
const store = createStore(reducer, applyMiddleware(thunk), window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()); | ||
|
||
render( | ||
<Provider store={store}> | ||
<App /> | ||
</Provider>, | ||
document.getElementById('root') | ||
); |
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,25 @@ | ||
/** | ||
* @file reducer | ||
* @date 2018/4/4 | ||
*/ | ||
|
||
import { combineReducers } from 'redux'; | ||
|
||
function mkds(state = [], action) { | ||
switch (action.type) { | ||
case 'ADD_MKD': | ||
return [ | ||
...state, | ||
{ | ||
id: action.id, | ||
title: '', | ||
value: '' | ||
} | ||
]; | ||
default: return state; | ||
} | ||
} | ||
|
||
export default combineReducers({ | ||
mkds | ||
}); |
Oops, something went wrong.