Skip to content

Commit 707426d

Browse files
committed
initial commit
0 parents  commit 707426d

38 files changed

+1354
-0
lines changed

.babelrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"presets": ["es2015-native-modules", "react"],
3+
"plugins": ["transform-runtime"]
4+
}

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[*.js]
2+
indent_style=space
3+
indent_size=2

.eslintrc

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
extends:
2+
eslint-config-airbnb
3+
4+
parser:
5+
babel-eslint
6+
7+
settings:
8+
ecmascript: 6
9+
10+
ecmaFeatures:
11+
jsx: true
12+
modules: true
13+
destructuring: true
14+
classes: true
15+
forOf: true
16+
blockBindings: true
17+
arrowFunctions: true
18+
19+
env:
20+
browser: true
21+
22+
rules:
23+
indent: 2
24+
func-style: 0
25+
func-names: 0
26+
comma-dangle: 0
27+
no-console: 0
28+
no-param-reassign: 0

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_STORE
2+
node_modules
3+
static
4+
.module-cache
5+
*.log*
6+
coverage
7+
__nogit
8+
.idea

README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# React Router Dynamic Route Loading w/ Webpack 2 Chunks
2+
3+
Webpack 2 automatically splits routes in chunks (small bundles) and loads them on demand.
4+
5+
## Contains
6+
7+
- [x] [Webpack 2](https://webpack.github.io)
8+
- [x] [React 0.15](https://facebook.github.io/react/)
9+
- [x] [Babel 6.5](https://babeljs.io/)
10+
11+
##System Requirements
12+
Before installing the dependencies, make sure your system has the correct Node and Npm versions, otherwise you will get errors.
13+
14+
- Node 5.x.x
15+
- Npm 3.x.x
16+
17+
## Setup
18+
19+
```
20+
$ npm install
21+
```
22+
23+
## Running
24+
25+
```
26+
$ npm start
27+
```
28+
29+
## Build
30+
31+
```
32+
$ npm run build
33+
```

build.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* eslint no-var: 0 */
2+
var exec = require('child_process').exec;
3+
4+
var cmdLine = './node_modules/.bin/webpack --progress';
5+
var environ = (!process.argv[2].indexOf('development')) ? 'development' : 'production';
6+
var command;
7+
8+
if (process.platform === 'win32') {
9+
cmdLine = 'set NODE_ENV=' + environ + '&& ' + cmdLine;
10+
} else {
11+
cmdLine = 'NODE_ENV=' + environ + ' ' + cmdLine;
12+
}
13+
14+
command = exec(cmdLine);
15+
16+
command.stdout.on('data', function(data) {
17+
process.stdout.write(data);
18+
});
19+
command.stderr.on('data', function(data) {
20+
process.stderr.write(data);
21+
});
22+
command.on('error', function(err) {
23+
process.stderr.write(err);
24+
});

client/_variables.scss

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
$light: #e6e6e6;
2+
$dark: #4d4d4d;
3+
$white: #ffffff;
4+
$grey: #7d7d7d;
5+
$red: #ec3d2b;
6+
$blue: #113d92;
7+
$lightBlue: #258ce7;

client/actions/index.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
export const ADD_TRANSACTION = 'ADD_TRANSACTION';
2+
export const DELETE_TRANSACTION = 'DELETE_TRANSACTION';
3+
export const GET_TRANSACTION_GRID_FIELDS = 'GET_TRANSACTION_GRID_FIELDS';
4+
export const REQUEST_SUM = 'REQUEST_SUM';
5+
6+
function createTransaction(transaction) {
7+
return {
8+
type: ADD_TRANSACTION,
9+
transaction
10+
};
11+
}
12+
13+
export function deleteTransaction(id) {
14+
return {
15+
type: ADD_TRANSACTION,
16+
id
17+
};
18+
}
19+
20+
export function requestSum(data) {
21+
return {
22+
type: REQUEST_SUM,
23+
data
24+
};
25+
}
26+
27+
export function addTransaction(transaction) {
28+
return (dispatch, getState) => {
29+
const addedResult = dispatch(createTransaction(transaction));
30+
dispatch(requestSum(getState().transactions.transactions));
31+
return addedResult;
32+
};
33+
}

client/actions/navigation.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { menuSections } from 'data/menu.json';
2+
3+
export const RECEIVE_MENU_SECTIONS = 'RECEIVE_MENU_SECTIONS';
4+
export const TOGGLE_MENU = 'TOGGLE_MENU';
5+
export const SELECT_MENU_SECTION = 'SELECT_MENU_SECTION';
6+
7+
export function toggleMenu() {
8+
return (dispatch, getState) => dispatch({
9+
type: TOGGLE_MENU,
10+
menuVisible: !getState().navigation.menu.menuVisible
11+
});
12+
}
13+
14+
export function loadMenuData() {
15+
return dispatch => dispatch({
16+
type: RECEIVE_MENU_SECTIONS,
17+
menuSections
18+
});
19+
}
20+
21+
export function selectMenuSection(menuSection) {
22+
return dispatch => dispatch({
23+
type: SELECT_MENU_SECTION,
24+
menuSection
25+
});
26+
}

client/components/Header/header.scss

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
@import "client/variables";
2+
3+
.header-container {
4+
background-color: $grey;
5+
padding: 10px;
6+
user-select: none;
7+
-webkit-user-select: none;
8+
9+
.header-title {
10+
color: $white;
11+
margin: 0;
12+
font-size: 1.4em;
13+
}
14+
15+
&.header-white {
16+
background-color: $white;
17+
.header-title {
18+
color: $dark;
19+
}
20+
}
21+
&.header-red {
22+
background-color: $red;
23+
}
24+
&.header-dark {
25+
background-color: $dark;
26+
}
27+
&.header-grey {
28+
background-color: $grey;
29+
}
30+
&.header-blue {
31+
background-color: $blue;
32+
}
33+
}

client/components/Header/index.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React, { PropTypes } from 'react';
2+
import './header.scss';
3+
4+
const { string } = PropTypes;
5+
6+
const Header = ({ title, className }) => {
7+
const styles = `header-container ${className}`;
8+
9+
return (
10+
<header className={styles}>
11+
<h1 className="header-title">{title}</h1>
12+
</header>
13+
);
14+
};
15+
16+
Header.propTypes = {
17+
className: string,
18+
title: string
19+
};
20+
21+
export default Header;

client/components/List/List.js

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import React, { Component, PropTypes } from 'react';
2+
import ListItem from './ListItem';
3+
import './list.scss';
4+
5+
const { number, node, array, bool, string } = PropTypes;
6+
7+
class List extends Component {
8+
constructor(props) {
9+
super(props);
10+
11+
this.state = { expanded: [] };
12+
}
13+
14+
onSelectItem(index) {
15+
const { collapsible, singleExpand } = this.props;
16+
17+
if (!collapsible) {
18+
return false;
19+
}
20+
21+
let { expanded } = this.state;
22+
const expandedIndex = expanded.indexOf(index);
23+
24+
if (expandedIndex > -1) {
25+
// collapse expanded item
26+
expanded = [
27+
...expanded.slice(0, expandedIndex),
28+
...expanded.slice(expandedIndex + 1)
29+
];
30+
} else if (singleExpand) {
31+
expanded = [index];
32+
} else {
33+
expanded = [...expanded, index];
34+
}
35+
36+
this.setState({ expanded });
37+
}
38+
39+
showListItems() {
40+
const me = this;
41+
const { items, collapsible } = me.props;
42+
const { expanded } = me.state;
43+
const onSelectItem = me.onSelectItem.bind(me);
44+
45+
return items.map((item, idx) => {
46+
const itemExpanded = !!(expanded.indexOf(idx) > -1);
47+
return (<ListItem
48+
{...item}
49+
onSelectItem={onSelectItem}
50+
collapsible={collapsible}
51+
expanded={itemExpanded}
52+
key={idx}
53+
index={idx}
54+
/>);
55+
});
56+
}
57+
58+
render() {
59+
const { columns, children, className } = this.props;
60+
return (
61+
<div className={`list columns-${columns} ${className}`}>
62+
{ this.showListItems() }
63+
{ children }
64+
</div>
65+
);
66+
}
67+
}
68+
69+
List.propTypes = {
70+
columns: number,
71+
children: node,
72+
items: array,
73+
collapsible: bool,
74+
className: string,
75+
singleExpand: bool
76+
};
77+
78+
List.defaultProps = {
79+
columns: 1,
80+
className: '',
81+
items: [],
82+
collapsible: false,
83+
singleExpand: true
84+
};
85+
86+
export default List;

0 commit comments

Comments
 (0)