Skip to content

Commit c28acf6

Browse files
committed
initial commit
0 parents  commit c28acf6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1400
-0
lines changed

.babelrc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"presets": [
3+
"es2015",
4+
"react"
5+
],
6+
"plugins": [
7+
"transform-class-properties",
8+
"transform-decorators",
9+
"transform-object-rest-spread"
10+
]
11+
}

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.eslintrc

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"parser": "babel-eslint",
3+
"rules": {
4+
"indent": [
5+
2,
6+
2,
7+
{ "SwitchCase": 1 }
8+
],
9+
"quotes": [
10+
2,
11+
"single"
12+
],
13+
"react/jsx-uses-react": 1,
14+
"linebreak-style": [
15+
2,
16+
"unix"
17+
],
18+
"no-console": 0,
19+
"no-unused-vars": [1],
20+
"semi": [
21+
2,
22+
"always"
23+
]
24+
},
25+
"env": {
26+
"browser": true,
27+
"es6": true,
28+
"mocha": true,
29+
"node": true
30+
},
31+
"globals": {
32+
"__CORDOVA__": true,
33+
"__PRODUCTION__": true,
34+
"__DEVELOPMENT__": true,
35+
"__BASE_URL__": true
36+
},
37+
"extends": "eslint:recommended",
38+
"ecmaFeatures": {
39+
"jsx": true,
40+
"experimentalObjectRestSpread": true
41+
},
42+
"plugins": [
43+
"react"
44+
]
45+
}

.gitignore

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
node_modules
2+
npm-debug.log*
3+
.DS_Store
4+
5+
# ignore built static files
6+
dist/
7+
webpack-assets.json
8+
9+
# cordova ignores
10+
cordova/www/*
11+
cordova/www/**.*
12+
!cordova/www/.gitkeep
13+
cordova/plugins/
14+
cordova/platforms/
15+
16+
# cordova build config
17+
cordova-build/*.json
18+
cordova-build/config/*.json

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-exact=true

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v4.2.4

README.md

+218
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
# react-redux-starter
2+
3+
A universal starter kit built with react, react-router and redux. Server
4+
rendering with react and express, bundles with Webpack with hot module reloading
5+
and hot style reloading with SCSS support. Bonus: Cordova support.
6+
7+
## Prerequisites
8+
9+
* Node >4.2.x is recommended.
10+
11+
* Webpack
12+
```
13+
npm install -g webpack
14+
```
15+
16+
* nodemon
17+
18+
```
19+
npm install -g nodemon
20+
```
21+
22+
* eslint, babel-eslint
23+
24+
```
25+
npm install -g eslint babel-eslint
26+
```
27+
28+
## Get started
29+
30+
```
31+
npm install
32+
npm start
33+
```
34+
35+
Direct your browser to `http://localhost:3000`.
36+
37+
38+
## Directory Structure
39+
```
40+
├── client # Client-side code.
41+
├── common # Shared code between client and server.
42+
│   ├── assets # All fonts, images, stylsheets.
43+
│   │   ├── fonts
44+
│   │   ├── images
45+
│   │   └── stylesheets # Follows the 7-1 pattern: http://sass-guidelin.es/#the-7-1-pattern
46+
│   │   ├── base
47+
│   │   ├── components
48+
│   │   ├── layout
49+
│   │   ├── pages
50+
│   │   ├── shame
51+
│   │   ├── utils
52+
│   │   └── vendors
53+
│   ├── config # Contains the redux store configuration. Add anything else you like.
54+
│   ├── middleware # Custom redux middleware can be placed here.
55+
│   ├── reducers # Redux reducers
56+
| | └── index.js # Root reducer. Imports all other reducers.
57+
│   ├── routes # Routes each have an index.js which exports a react-router Route.
58+
│   │   ├── app
59+
│   │   │   ├── components
60+
│   │   │   ├── containers
61+
│   │   │   └── index.js
62+
│   │   ├── example # The name of route.
63+
│   │   │   ├── components # "Dumb" components
64+
│   │   │   └── containers # "Smart" containers
65+
│   │   │   └── index.js # Exports a react-router route. Uses [alternate configuration](https://github.com/rackt/react-router/blob/master/docs/guides/basics/RouteConfiguration.md#alternate-configuration)
66+
│   │   └── home
67+
│   │   └── containers
68+
│   │   │   └── index.js
69+
│   ├── selectors # Memoized selectors. See https://github.com/rackt/reselect
70+
│   ├── shared # Shared actions and components and do not belong to a single route.
71+
│   │   ├── actions
72+
│   │   └── components
73+
│   ├── templates # HTML templates
74+
│   └── util # Utility methods
75+
├── cordova-build # Cordova build tools
76+
│   └── config
77+
├── server # Server-side code.
78+
└── webpack # Webpack configuration files.
79+
```
80+
81+
## Writing Tests
82+
The default testing framework is Mocha, though you can use whatever you want.
83+
Make sure you have it installed:
84+
85+
```
86+
npm install -g mocha
87+
```
88+
89+
Tests should reside alongside the component/module/selector/etc that it is
90+
testing. For example:
91+
92+
```
93+
├── reducers
94+
│   ├── todos.js
95+
│   ├── todos.test.js
96+
```
97+
98+
Tests can be written with ES2015, since it passes through `babel-register`.
99+
100+
## Running Tests
101+
To run a single test:
102+
```
103+
npm test /path/to/single.test.js
104+
```
105+
106+
To run a directory of tests:
107+
108+
```
109+
npm test /path/to/test/directory
110+
```
111+
112+
To run all tests:
113+
114+
```
115+
npm run test:all
116+
```
117+
118+
This will run all files that are suffixed with a `.test.js`.
119+
120+
## Deploying to Heroku
121+
122+
Just set an environment variable to point the asset host to whereever you want,
123+
since it defaults to `localhost:3001`. If using Heroku to store assets, just use
124+
a local route. Otherwise, set it to the CDN of your choice.
125+
```
126+
heroku config:set ASSET_HOST=/dist/
127+
# OR
128+
heroku config:set ASSET_HOST=https://s3.amazonaws.com/mybucket/myasssets/
129+
```
130+
131+
## Building Cordova Apps
132+
133+
First, make sure you have Cordova installed:
134+
135+
```
136+
npm install -g cordova
137+
```
138+
139+
Initialize the Cordova app:
140+
141+
```
142+
cordova create cordova/ com.org.appname "My App"
143+
```
144+
145+
Add the platform(s) you want to build for:
146+
147+
```
148+
cd cordova/
149+
cordova platform add ios # or 'android'
150+
```
151+
152+
Install plugins (if you don't have a `/plugins` folder)
153+
```
154+
cordova prepare
155+
```
156+
157+
### Build/Start Dev Environment
158+
159+
```
160+
npm run start:cordova # build for development with hot reloading
161+
npm run build:cordova # build for development without hot reloading
162+
npm run build:cordova:development # alias for above
163+
npm run build:cordova:production # build for production without hot reloading
164+
```
165+
166+
### Start a simulator/emulator
167+
168+
* iOS - CLI
169+
170+
Install XCode, then:
171+
172+
```
173+
npm install -g ios-deploy
174+
cd cordova && cordova run ios
175+
```
176+
177+
* iOS - XCode
178+
179+
Open the file located in `./cordova/platforms/ios/MarcasDirectos.xcodeproj`.
180+
181+
* Android - CLI
182+
183+
Install the Android SDK, then:
184+
```
185+
cd cordova && cordova run android
186+
```
187+
188+
## Distributing Betas
189+
190+
You may want to distribute the app via Fabric (Crashlytics). To do so, prepare
191+
the following files (copy and rename them):
192+
193+
```
194+
build/fabric.json.example -> build/fabric.json
195+
build/config/release.json.example -> build/config/release.json
196+
```
197+
198+
Fill in the fields in the JSON files properly, then run the following commands:
199+
200+
```
201+
npm run build:cordova:production # build the source files for cordova's www
202+
npm run dist:android # build the binary and upload to Crashlytics
203+
# OR
204+
npm run dist:ios
205+
```
206+
207+
## Additional Notes
208+
209+
If you're debugging in a mobile browser and you want to access your project
210+
locally, do the following:
211+
212+
- Make sure your mobile device on the same network as your desktop/laptop.
213+
- Run `npm start` with a `HOSTNAME` environment variable set to your computer's
214+
local ip address (the computer that your dev environment is on):
215+
```
216+
HOSTNAME=10.0.1.3 npm start
217+
```
218+
- Browse to `http://10.0.1.3:3000` on your mobile device.

client/index.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import 'babel-polyfill';
2+
import React from 'react';
3+
import ReactDOM from 'react-dom';
4+
import { Provider } from 'react-redux';
5+
import { Router } from 'react-router';
6+
import { routes } from '../common/routes';
7+
import configureStore from '../common/config/store';
8+
import { browserHistory, hashHistory } from 'react-router';
9+
10+
/* Images
11+
* This space is reserved for images that are required by server rendering,
12+
* e.g. the favicon and any other images that need to be in the base HTML file.
13+
*/
14+
import '../common/assets/images/favicon.png';
15+
16+
/* Stylesheets
17+
* Main.scss should @import all the other stylesheets that you need. If you want
18+
* to use LESS or another preprocessor, you can include it here and update your
19+
* webpack configure to use the appropriate loader.
20+
*/
21+
import '../common/assets/stylesheets/main.scss';
22+
23+
// The root element of your app
24+
const rootElement = document.getElementById('app');
25+
26+
// Creates the Redux store based on the initial state passed down by the server
27+
// rendering.
28+
const history = __CORDOVA__ ? hashHistory : browserHistory;
29+
const initialState = window.__INITIAL_STATE__;
30+
const store = configureStore(initialState, {
31+
history: history,
32+
dispatchRouteChanges: true,
33+
rootElement: rootElement
34+
});
35+
36+
/* FastClick
37+
* Disables the 300ms delay for mobile apps. Comment out or add a conditional
38+
* for __CORDOVA__ if you only want this in your Cordova app.
39+
*/
40+
document.addEventListener('DOMContentLoaded', () => {
41+
require('fastclick').attach(document.body);
42+
}, false);
43+
44+
// Render the app!
45+
ReactDOM.render(
46+
<Provider store={store}>
47+
<Router history={history} routes={routes} />
48+
</Provider>,
49+
rootElement
50+
);

common/assets/fonts/.gitkeep

Whitespace-only changes.

common/assets/images/favicon.png

1.27 KB
Loading
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Base layout styles for HTML and body
2+
html, body {
3+
height: 100%;
4+
}
5+
6+
body {
7+
background: white;
8+
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
9+
font-size: 13px;
10+
color: black;
11+
padding: 15px;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Add typography styles and imports, @font-face declarations, etc.
2+
//
3+
// For example:
4+
// @import url("https://fonts.googleapis.com/css?family=Roboto+Slab:300");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
header > ul {
2+
padding: 0;
3+
list-style: none;
4+
}
5+
header > ul > li {
6+
display: inline-block;
7+
margin-right: 15px;
8+
}
9+
header > ul > li > a {
10+
display: block;
11+
text-decoration: underline;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// footer styles
2+
footer {
3+
4+
}

0 commit comments

Comments
 (0)