Skip to content

Commit

Permalink
layout
Browse files Browse the repository at this point in the history
  • Loading branch information
viviier committed Apr 3, 2018
1 parent 87613bb commit bfd15b2
Show file tree
Hide file tree
Showing 14 changed files with 21,217 additions and 0 deletions.
2,444 changes: 2,444 additions & 0 deletions mkd-app/README.md

Large diffs are not rendered by default.

11,417 changes: 11,417 additions & 0 deletions mkd-app/package-lock.json

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions mkd-app/package.json
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 added mkd-app/public/favicon.ico
Binary file not shown.
40 changes: 40 additions & 0 deletions mkd-app/public/index.html
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>
15 changes: 15 additions & 0 deletions mkd-app/public/manifest.json
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"
}
13 changes: 13 additions & 0 deletions mkd-app/src/actions/index.js
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()
};
}
68 changes: 68 additions & 0 deletions mkd-app/src/components/home/index.js
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;
24 changes: 24 additions & 0 deletions mkd-app/src/components/home/listItem/index.js
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>
)
};
}
7 changes: 7 additions & 0 deletions mkd-app/src/components/home/listItem/style.less
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;
}
15 changes: 15 additions & 0 deletions mkd-app/src/components/index.js
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>
);
}
}
21 changes: 21 additions & 0 deletions mkd-app/src/index.js
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')
);
25 changes: 25 additions & 0 deletions mkd-app/src/reducers/index.js
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
});
Loading

0 comments on commit bfd15b2

Please sign in to comment.