-
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.
Added RFR / sample page, updated storybook
- Loading branch information
Showing
30 changed files
with
567 additions
and
299 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"presets": ["stage-2", "es2015", "react"] | ||
"plugins": ["universal-import"], | ||
"presets": ["stage-2", "es2017", "react"] | ||
} |
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,2 +1,3 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import '@storybook/addon-actions/register'; | ||
import '@storybook/addon-links/register'; |
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,4 @@ | ||
import exportAllDefaults from '../utils/exportAllDefaults'; | ||
|
||
const context = require.context('.', false, /\.js/); | ||
export default exportAllDefaults(context); |
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,12 @@ | ||
// ADD_PLANT, UPDATE_PLANT, DELETE_PLANT, GET_PLANT, | ||
import { LIST_PLANTS, SET_PLANTS } from '../constants/actionTypes'; | ||
import * as api from '../constants/apiTypes'; | ||
import makeActionCreator from '../utils/makeActionCreator'; | ||
import apiActionCreator from '../utils/apiActionCreator'; | ||
|
||
// export const createPlant = makeActionCreator(ADD_PLANT, 'plant'); | ||
// export const updatePlant = makeActionCreator(UPDATE_PLANT, 'id', 'plant'); | ||
// export const getPlant = makeActionCreator(GET_PLANT, 'id'); | ||
// export const deletePlant = makeActionCreator(DELETE_PLANT, 'id'); | ||
export const listPlants = apiActionCreator(LIST_PLANTS, api.GET_PLANTS, 'gardenId'); | ||
export const setPlants = makeActionCreator(SET_PLANTS, 'gardenId', 'plants'); |
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,10 @@ | ||
export const API_LOADING = 'API_LOADING'; | ||
export const API_SUCCESS = 'API_SUCCESS'; | ||
export const API_ERROR = 'API_ERROR'; | ||
|
||
export const ADD_PLANT = 'ADD_PLANT'; | ||
export const UPDATE_PLANT = 'UPDATE_PLANT'; | ||
export const DELETE_PLANT = 'DELETE_PLANT'; | ||
export const GET_PLANT = 'GET_PLANT'; | ||
export const LIST_PLANTS = 'LIST_PLANTS'; | ||
export const SET_PLANTS = 'SET_PLANTS'; |
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,2 @@ | ||
export const GET_PLANTS = 'getPlants'; | ||
export const GET_GARDENS = 'getGardens'; |
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,12 @@ | ||
const context = require.context('../containers/pages', false, /\.jsx/); | ||
const pageNames = {}; | ||
context.keys().forEach((key) => { | ||
if (key !== '.' && key !== '..') { | ||
const name = key.replace(/\.\//, '').split('.')[0]; | ||
if (name !== 'index') { | ||
pageNames[name] = name; | ||
} | ||
} | ||
}); | ||
|
||
export default pageNames; |
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,14 +1,24 @@ | ||
import React, { Fragment } from 'react'; | ||
import Router from '../../init/router'; | ||
|
||
const App = () => ( | ||
<Fragment> | ||
<header></header> | ||
<main id="main"> | ||
<Router /> | ||
</main> | ||
<footer id="footer"></footer> | ||
</Fragment> | ||
); | ||
|
||
export default App; | ||
import React, { Fragment } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import PropTypes from 'prop-types'; | ||
import universal from 'react-universal-component'; | ||
|
||
const UniversalComponent = universal(({ page }) => import(`../pages/${page}`)); | ||
|
||
const App = ({ page }) => ( | ||
<Fragment> | ||
<header /> | ||
<main id="main"> | ||
<UniversalComponent page={page} /> | ||
</main> | ||
<footer id="footer" /> | ||
</Fragment> | ||
); | ||
|
||
const mapStateToProps = ({ page }) => ({ page }); | ||
|
||
export default connect(mapStateToProps)(App); | ||
|
||
App.propTypes = { | ||
page: PropTypes.string.isRequired, | ||
}; |
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,27 @@ | ||
|
||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const GardenPage = props => ( | ||
<div> | ||
{props.plants.map(garden => <div key={garden.id}>{ garden.name }</div>)} | ||
</div> | ||
); | ||
|
||
const mapStateToProps = state => ({ | ||
plants: state.plants, | ||
}); | ||
export default connect(mapStateToProps)(GardenPage); | ||
|
||
GardenPage.propTypes = { | ||
plants: PropTypes.arrayOf(PropTypes.shape({ | ||
id: PropTypes.int, | ||
name: PropTypes.string, | ||
daysTillHarvest: PropTypes.int, | ||
})), | ||
}; | ||
|
||
GardenPage.defaultProps = { | ||
plants: [], | ||
}; |
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,10 @@ | ||
|
||
import React from 'react'; | ||
|
||
const NotFoundPage = () => ( | ||
<div> | ||
Home Page | ||
</div> | ||
); | ||
|
||
export default NotFoundPage; |
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,10 @@ | ||
|
||
import React from 'react'; | ||
|
||
const NotFoundPage = () => ( | ||
<div> | ||
Page Not Found | ||
</div> | ||
); | ||
|
||
export default NotFoundPage; |
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,4 @@ | ||
import exportAllDefaults from '../../utils/exportAllDefaults'; | ||
|
||
const context = require.context('.', false, /\.jsx/); | ||
export default exportAllDefaults(context); |
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,33 @@ | ||
import * as api from '../constants/apiTypes'; | ||
|
||
function Api(name, ...params) { | ||
return typeof Api[name] === 'function' ? Api[name](...params) : null; | ||
} | ||
|
||
Api[api.GET_PLANTS] = (gardenId) => { | ||
const response = { | ||
success: true, | ||
data: { | ||
gardenId, | ||
plants: [ | ||
{ id: 1, name: 'strawberry', daysTillHarvest: 80 }, | ||
], | ||
}, | ||
}; | ||
|
||
// fetch(...) | ||
// for now simulating delay with a promise that takes time to resolve | ||
return new Promise(resolve => setTimeout(resolve, 1000)).then(() => { | ||
if (response.success !== true || typeof response.data === 'undefined') { | ||
if (response.error) { | ||
throw Error(response.error); | ||
} else { | ||
throw Error('Invalid Response'); | ||
} | ||
} | ||
|
||
return response.data; | ||
}); | ||
}; | ||
|
||
export default Api; |
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,4 +1,5 @@ | ||
// logging | ||
import { createLogger } from 'redux-logger'; | ||
|
||
exports.initDev = (middleware) => middleware.push(createLogger()); | ||
// logging | ||
import { createLogger } from 'redux-logger'; | ||
|
||
const initDev = middleware => middleware.push(createLogger()); | ||
export default initDev; |
Oops, something went wrong.