Skip to content
This repository was archived by the owner on Sep 6, 2022. It is now read-only.

Commit 5aa6594

Browse files
committed
Commenting out the entire application
1 parent 5a6f624 commit 5aa6594

37 files changed

+237
-59
lines changed

app/app.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/**
2-
*
32
* app.js
43
*
5-
* This is the entry file for the application, mostly just setup and boilerplate
6-
* code. Routes are configured at the end of this file!
7-
*
4+
* This is the entry file for the application, only setup and boilerplate
5+
* code.
86
*/
97

108
import 'babel-polyfill';
@@ -27,30 +25,25 @@ import { fromJS } from 'immutable';
2725
const reduxRouterMiddleware = syncHistory(browserHistory);
2826
import sagaMiddleware from 'redux-saga';
2927

30-
// Observer loading of Open Sans (to remove open sans, remove the <link> tag in
28+
// Observe loading of Open Sans (to remove open sans, remove the <link> tag in
3129
// the index.html file and this observer)
3230
import styles from './containers/App/styles.css';
3331
const openSansObserver = new FontFaceObserver('Open Sans', {});
3432

35-
// When Open Sans is loaded, add the js-open-sans-loaded class to the body
33+
// When Open Sans is loaded, add a font-family using Open Sans to the body
3634
openSansObserver.check().then(() => {
3735
document.body.classList.add(styles.fontLoaded);
3836
}, () => {
3937
document.body.classList.remove(styles.fontLoaded);
4038
});
4139

42-
// Import the pages
43-
import App from 'App';
44-
45-
// Import the CSS file, which HtmlWebpackPlugin transfers to the build folder
40+
// Import the CSS reset, which HtmlWebpackPlugin transfers to the build folder
4641
import '../node_modules/sanitize.css/dist/sanitize.min.css';
4742

48-
/*
49-
* Create the store with two middlewares :
50-
* 1. redux-thunk : Allow us to asynchronous things in the actions
51-
* 2. reduxRouterMiddleware : Sync dispatched route actions to the history
52-
*/
53-
43+
// Create the store with two middlewares
44+
// 1. sagaMiddleware: Imports all the asynchronous flows ("sagas") from the
45+
// sagas folder and triggers them
46+
// 2. reduxRouterMiddleware: Syncs the location/URL path to the state
5447
import rootReducer from './rootReducer';
5548
import sagas from './sagas';
5649
const createStoreWithMiddleware = applyMiddleware(reduxRouterMiddleware, sagaMiddleware(...sagas))(createStore);
@@ -66,6 +59,7 @@ if (module.hot) {
6659
}
6760

6861
// Set up the router, wrapping all Routes in the App component
62+
import App from 'App';
6963
import routes from './routes';
7064
const rootRoute = {
7165
component: App,

app/components/A/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import React from 'react';
1+
/**
2+
* A link to a certain page, an anchor tag
3+
*/
4+
5+
import React, { PropTypes } from 'react';
26

37
import styles from './styles.css';
48

@@ -18,4 +22,10 @@ class A extends React.Component {
1822
}
1923
}
2024

25+
A.propTypes = {
26+
className: PropTypes.string,
27+
href: PropTypes.string.isRequired,
28+
target: PropTypes.string
29+
};
30+
2131
export default A;

app/components/A/index.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Testing our link component
3+
*/
4+
15
import A from './index';
26

37
import expect from 'expect';

app/components/Button/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ import styles from './styles.css';
1212

1313
function Button(props) {
1414
const className = props.className ? props.className : styles.button;
15+
// Render an anchor tag
1516
let button = (
1617
<a className={className} href={props.href} onClick={props.onClick}>{props.children}</a>
1718
);
1819

19-
20+
// If the Button has a handleRoute prop, we want to render a button
2021
if (props.handleRoute) {
2122
button = (
2223
<button className={className} onClick={ props.handleRoute } >{props.children}</button>

app/components/Button/index.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Testing our Button component
3+
*/
4+
15
import Button from './index';
26

37
import expect from 'expect';

app/components/List/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ class List extends React.Component {
66
render() {
77
const ComponentToRender = this.props.component;
88
let content = (<div></div>);
9+
// If we have items, render them
910
if (this.props.items) {
1011
content = this.props.items.map((item, index) => (
1112
<ComponentToRender key={'item-' + index } item={item} />
1213
));
1314
} else {
15+
// Otherwise render a single component
1416
content = (<ComponentToRender />);
1517
}
1618

app/containers/App/actions.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,52 @@ import {
2222
LOAD_REPOS_ERROR
2323
} from './constants';
2424

25+
/**
26+
* Changes the input field of the form
27+
*
28+
* @param {name} name The new text of the input field
29+
*
30+
* @return {object} An action object with a type of CHANGE_USERNAME
31+
*/
2532
export function changeUsername(name) {
2633
return {
2734
type: CHANGE_USERNAME,
2835
name
2936
};
3037
}
3138

39+
/**
40+
* Load the repositories, this action starts the getGithubData saga
41+
*
42+
* @return {object} An action object with a type of LOAD_REPOS
43+
*/
3244
export function loadRepos() {
3345
return {
3446
type: LOAD_REPOS
3547
};
3648
}
3749

50+
/**
51+
* Dispatched when the repositories are loaded by the getGithubData saga
52+
*
53+
* @param {array} repos The repository data
54+
*
55+
* @return {object} An action object with a type of LOAD_REPOS_SUCCESS passing the repos
56+
*/
3857
export function reposLoaded(repos) {
3958
return {
4059
type: LOAD_REPOS_SUCCESS,
4160
repos
4261
};
4362
}
4463

64+
/**
65+
* Dispatched when loading the repositoreis fails
66+
*
67+
* @param {object} error The error
68+
*
69+
* @return {object} An action object with a type of LOAD_REPOS_ERROR passing the error
70+
*/
4571
export function repoLoadingError(error) {
4672
return {
4773
type: LOAD_REPOS_ERROR,

app/containers/App/constants.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
* AppConstants
33
* Each action has a corresponding type, which the reducer knows and picks up on.
44
* To avoid weird typos between the reducer and the actions, we save them as
5-
* constants here.
5+
* constants here. We prefix them with 'yourproject/YourComponent' so we avoid
6+
* reducers accidentally picking up actions they shouldn't.
67
*
78
* Follow this format:
8-
* export const YOUR_ACTION_CONSTANT = 'yourapp/YourContainer/YOUR_ACTION_CONSTANT';
9+
* export const YOUR_ACTION_CONSTANT = 'yourproject/YourContainer/YOUR_ACTION_CONSTANT';
910
*/
1011

1112
export const LOAD_REPOS = 'boilerplate/App/LOAD_REPOS';

app/containers/App/reducer.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* AppReducer
33
*
4-
* The reducer takes care of our data
5-
* Using actions, we can change our application state
4+
* The reducer takes care of our data. Using actions, we can change our
5+
* application state.
66
* To add a new action, add it to the switch statement in the reducer function
77
*
88
* Example:
@@ -18,6 +18,7 @@ import {
1818
} from './constants';
1919
import { fromJS } from 'immutable';
2020

21+
// The initial state of the App
2122
const initialState = fromJS({
2223
loading: false,
2324
error: false,
@@ -31,7 +32,7 @@ const initialState = fromJS({
3132
function globalReducer(state = initialState, action) {
3233
switch (action.type) {
3334
case CHANGE_USERNAME:
34-
// Delete prefixed '@' from github username
35+
// Delete prefixed '@' from the github username
3536
return state
3637
.setIn(['userData', 'username'], action.name.replace(/@/gi, ''));
3738
case LOAD_REPOS:

app/containers/FeaturePage/index.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@ import A from 'A';
1515
import styles from './styles.css';
1616

1717
export class FeaturePage extends React.Component {
18-
onChangeRoute = (url) => {
19-
this.props.changeRoute(url);
18+
/**
19+
* Changes the route
20+
*
21+
* @param {string} route The route we want to go to
22+
*/
23+
openRoute = (route) => {
24+
this.props.changeRoute(route);
2025
};
2126

22-
changeRouteToHome = () => {
23-
this.onChangeRoute('/');
27+
/**
28+
* Changed route to '/'
29+
*/
30+
openHomePage = () => {
31+
this.openRoute('/');
2432
};
2533

2634
render() {
@@ -47,7 +55,7 @@ export class FeaturePage extends React.Component {
4755
<p><A href="http://www.html5rocks.com/en/tutorials/service-worker/introduction/"><strong>ServiceWorker</strong></A> and <A href="http://www.html5rocks.com/en/tutorials/appcache/beginner/"><strong>AppCache</strong></A> make it possible to use the application offline. As soon as the website has been opened once, it is cached and available without a network connection. <A href="https://developer.chrome.com/multidevice/android/installtohomescreen"><strong><code className={ styles.code }>manifest.json</code></strong></A> is specifically for Chrome on Android. Users can add the website to the homescreen and use it like a native app!</p>
4856
</li>
4957
</ul>
50-
<Button handleRoute={ this.changeRouteToHome }>Home</Button>
58+
<Button handleRoute={ this.openHomePage }>Home</Button>
5159
</div>
5260
);
5361
}

0 commit comments

Comments
 (0)