Skip to content

Commit 84008fd

Browse files
author
Lee Powell
committed
Initial commit
1 parent 5c9c245 commit 84008fd

22 files changed

+770
-1
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
src/jspm_packages
2+
src/config.js

.eslintrc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"rules": {
3+
"indent": [
4+
2,
5+
2
6+
],
7+
"quotes": [
8+
2,
9+
"single"
10+
],
11+
"linebreak-style": [
12+
2,
13+
"unix"
14+
],
15+
"semi": [
16+
2,
17+
"always"
18+
]
19+
},
20+
"env": {
21+
"es6": true,
22+
"browser": true
23+
},
24+
"extends": "eslint:recommended",
25+
"ecmaFeatures": {
26+
"jsx": true,
27+
"experimentalObjectRestSpread": true,
28+
"modules": true
29+
},
30+
"plugins": [
31+
"react"
32+
]
33+
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
npm-debug.log
3+
.eslintcache

.jshintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"esnext": true
3+
}

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,20 @@
1-
# todolist_react
1+
# To Do List - React
22
Simple 'To Do' list built with JSPM, System.js and React.
3+
4+
To install simply clone this repo to your local environment, fire up a terminal and change directory into the newly cloned root then execute:
5+
6+
$ npm install
7+
8+
This will then grab all the NPM and JSPM dependencies. Once that's finished run the following:
9+
10+
$ npm run server:dist
11+
12+
Open up your favourite browser (ideally a Webkit based one) and visit: `http://localhost:8080`
13+
14+
## To Do (no pun intended)
15+
16+
This was a quite a rushed build to play around with React. It could do with a refactor after I have time to read all their documentation.
17+
18+
* Add some tests (should have done this from the start)
19+
* Read up on Flux and their approach to structuring a React app, I can already see that my current approach wouldn't scale very well
20+
* Refactor the data store

dist/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Document</title>
6+
<link rel="stylesheet" href="styles.css">
7+
</head>
8+
<body class="page">
9+
<div class="container-fluid">
10+
<h1 class="page__heading">My To Do List</h1>
11+
<div id="app">Loading ...</div>
12+
</div>
13+
<script src="scripts.js"></script>
14+
<script>
15+
System.import('app');
16+
</script>
17+
</body>
18+
</html>

dist/scripts.js

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/styles.css

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "todo-list-react",
3+
"version": "1.0.0",
4+
"description": "Simple 'To Do' list built with JSPM, System.js and React.",
5+
"author": "Lee Powell <lee@leepowell.co.uk> (https://leepowell.co.uk/)",
6+
"license": "MIT",
7+
"scripts": {
8+
"server:dev": "NODE_ENV=development node scripts/server.js",
9+
"server:dist": "NODE_ENV=production node scripts/server.js",
10+
"jspm": "jspm bundle app .tmp/app.bundle.js --minify --skip-source-maps",
11+
"usemin": "usemin src/index.html -d .tmp -o dist/index.html",
12+
"uglify": "uglifyjs .tmp/scripts.js .tmp/app.bundle.js -o dist/scripts.js",
13+
"lint": "eslint src --cache",
14+
"test": "echo \"RUN TEST HERE\"",
15+
"mkdirs": "mkdirp .tmp dist",
16+
"clean": "npm run clean:tmp -s && npm run clean:dist",
17+
"clean:tmp": "rimraf .tmp",
18+
"clean:dist": "rimraf dist",
19+
"prebuild": "npm run clean -s && npm run test -s && npm run mkdirs -s",
20+
"prebuild:js": "npm run lint -s",
21+
"build": "npm run build:html -s && npm run build:js -s && npm run build:css -s",
22+
"build:js": "npm run jspm -s && npm run usemin -s && npm run uglify -s",
23+
"build:css": "cp .tmp/styles.css dist/styles.css",
24+
"build:html": "npm run usemin -s",
25+
"postbuild": "npm run clean:tmp -s",
26+
"postinstall": "jspm install",
27+
"prepublish": "npm run build"
28+
},
29+
"devDependencies": {
30+
"eslint": "^1.7.3",
31+
"eslint-plugin-react": "^3.6.3",
32+
"express": "^4.13.3",
33+
"install": "^0.1.8",
34+
"jspm": "^0.16.13",
35+
"mkdirp": "^0.5.1",
36+
"npm": "^3.3.9",
37+
"rimraf": "^2.4.3",
38+
"serve-static": "^1.10.0",
39+
"uglify-js": "^2.5.0",
40+
"usemin-cli": "0.0.7"
41+
},
42+
"jspm": {
43+
"directories": {
44+
"baseURL": "src"
45+
},
46+
"dependencies": {
47+
"bootstrap": "github:twbs/bootstrap@^3.3.5",
48+
"lodash": "npm:lodash@^3.10.1",
49+
"node-uuid": "npm:node-uuid@^1.4.3",
50+
"react": "npm:react@^0.14.0",
51+
"react-time": "npm:react-time@^4.0.0",
52+
"store": "npm:store@^1.3.17"
53+
},
54+
"devDependencies": {
55+
"babel": "npm:babel-core@^5.8.24",
56+
"babel-runtime": "npm:babel-runtime@^5.8.24",
57+
"core-js": "npm:core-js@^1.1.4"
58+
}
59+
}
60+
}

scripts/server.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use strict';
2+
3+
const path = require('path');
4+
const express = require('express');
5+
const serveStatic = require('serve-static');
6+
const app = express();
7+
8+
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === undefined) {
9+
10+
app.use(serveStatic(
11+
path.resolve(__dirname, '..', 'src'),
12+
{
13+
setHeaders: setHeaders
14+
}
15+
));
16+
}
17+
18+
if (process.env.NODE_ENV === 'production') {
19+
app.use(serveStatic(
20+
path.resolve(__dirname, '..', 'dist')
21+
));
22+
}
23+
24+
app.listen(process.env.PORT || 8080);
25+
26+
function setHeaders(res, path) {
27+
if (path.indexOf('jspm_packages') > -1)
28+
res.setHeader('Cache-Control', 'public, max-age=86400000');
29+
}

0 commit comments

Comments
 (0)