From e3c645061ee23bee27d8f09dccfd48f11caf3b9f Mon Sep 17 00:00:00 2001 From: Alex Windett Date: Mon, 21 Nov 2016 14:10:05 +0000 Subject: [PATCH] Adding in fake data to infinite scroll list --- spikes/list/react-infinite/package.json | 9 +++++- spikes/list/react-infinite/src/actions.js | 7 +++-- spikes/list/react-infinite/src/list.js | 36 ++++++++++++++++++++-- spikes/list/react-infinite/webpack/base.js | 28 ++++++++++++++++- 4 files changed, 73 insertions(+), 7 deletions(-) diff --git a/spikes/list/react-infinite/package.json b/spikes/list/react-infinite/package.json index fff5aa4e..e5234f53 100644 --- a/spikes/list/react-infinite/package.json +++ b/spikes/list/react-infinite/package.json @@ -28,7 +28,14 @@ "babel-plugin-transform-object-rest-spread": "^6.19.0", "babel-preset-es2015": "^6.18.0", "babel-preset-react": "^6.16.0", + "extract-text-webpack-plugin": "^2.0.0-beta.4", + "faker": "^3.1.0", "webpack": "^2.1.0-beta.27", - "webpack-dev-server": "^1.16.2" + "webpack-dev-server": "^1.16.2", + "css-loader": "^0.25.0", + "postcss-nested": "^1.0.0", + "postcss-loader": "^1.0.0", + "postcss-modules-values": "^1.2.2", + "style-loader": "^0.13.1" } } diff --git a/spikes/list/react-infinite/src/actions.js b/spikes/list/react-infinite/src/actions.js index a72ba725..103c0868 100644 --- a/spikes/list/react-infinite/src/actions.js +++ b/spikes/list/react-infinite/src/actions.js @@ -1,5 +1,6 @@ const buildArray = require('build-array'); const delay = require('delay'); +const faker = require('faker'); const actions = { 'FETCH_FULFILLED': (state, action) => { @@ -53,7 +54,10 @@ const fetch = () => (dispatch, getState) => { return { id, - title: `test ${id}` + title: `test ${id}`, + description: faker.lorem.sentence(), + image: faker.image.imageUrl(), + date: faker.date.recent() }; }); }) @@ -85,4 +89,3 @@ module.exports = (state, action) => { module.exports.fetch = fetch; module.exports.filter = filter; - diff --git a/spikes/list/react-infinite/src/list.js b/spikes/list/react-infinite/src/list.js index e5e6f151..425b4cd3 100644 --- a/spikes/list/react-infinite/src/list.js +++ b/spikes/list/react-infinite/src/list.js @@ -28,6 +28,27 @@ const mapDispatchToProps = (dispatch, ownProps) => { } }; +const styles = { + item: { + borderRadius: '4px', + backgroundColor: '#ffffff', + boxShadow: '0 2px 0 0 rgba(0, 0, 0, 0.05)', + border: 'solid 1px #d8d8d8', + marginBottom: '20px', + padding: '20px', + clear: 'both' + }, + itemImage: { + width: '25%', + float: 'left', + width: '150px', + height: '150px' + }, + itemText: { + float: 'right', + paddingLeft: '20px' + } +} const List = ({ items = [], filtered, @@ -37,9 +58,18 @@ const List = ({ filter }) => { const _items = (filtered || items).map((item) => { + const fill = Math.random() > 0.5 ? 'red' : 'green'; + const status = Math.random() > 0.5 ? 'Unhealthy' : 'Healthy'; + return ( -
- {item.title} +
+ {item.title} +

{item.title}

+

{status}

+

{item.description}

+ + +
); }); @@ -57,7 +87,7 @@ const List = ({