Skip to content

Commit 2ca16df

Browse files
committed
Firebase - Section 2
1 parent 049b3c8 commit 2ca16df

File tree

7 files changed

+199
-0
lines changed

7 files changed

+199
-0
lines changed

todos/.gitignore

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

todos/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
ReactStarter
2+
====
3+
4+
Use this as a starting point for working on chapters of the [Learn and Understand React JS](https://www.udemy.com/learn-and-understand-reactjs/) course on Udemy.com.
5+
6+
---
7+
8+
###Getting Started###
9+
10+
There are two methods for getting started with this repo.
11+
12+
####Familiar with Git?#####
13+
Checkout this repo, install depdencies, then start the gulp process with the following:
14+
15+
```
16+
> git clone [email protected]:StephenGrider/ReactStarter.git
17+
> cd ReactStarter
18+
> npm install
19+
> gulp
20+
```
21+
22+
####Not Familiar with Git?#####
23+
Click [here](https://github.com/StephenGrider/ReactStarter/releases) then download the .zip file. Extract the contents of the zip file, then open your terminal, change to the project directory, and:
24+
25+
```
26+
> npm install
27+
> gulp
28+
```

todos/application.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
var options = {
2+
thumbnailData: [{
3+
title: 'Show Courses',
4+
number: 12,
5+
header: 'Learn React',
6+
description: 'React is a fantastic new front end library for rendering web pages. React is a fantastic new front end library for rendering web pages.',
7+
imageUrl: 'https://raw.githubusercontent.com/wiki/facebook/react/react-logo-1000-transparent.png'
8+
},{
9+
title: 'Show Courses',
10+
number: 25,
11+
header: 'Learn Gulp',
12+
description: 'Gulp will speed up your development workflow. Gulp will speed up your development workflow. Gulp will speed up your development workflow.',
13+
imageUrl: 'http://brunch.io/images/others/gulp.png'
14+
}]
15+
};
16+
17+
var element = React.createElement(ThumbnailList, options);
18+
React.render(element, document.querySelector('.container'));
19+
20+
var Badge = React.createClass({displayName: "Badge",
21+
render: function() {
22+
return React.createElement("button", {className: "btn btn-primary", type: "button"},
23+
this.props.title, " ", React.createElement("span", {className: "badge"}, this.props.number)
24+
)
25+
}
26+
});
27+
28+
var ThumbnailList = React.createClass({displayName: "ThumbnailList",
29+
render: function() {
30+
var list = this.props.thumbnailData.map(function(thumbnailProps){
31+
return React.createElement(Thumbnail, React.__spread({}, thumbnailProps))
32+
});
33+
34+
return React.createElement("div", null,
35+
list
36+
)
37+
}
38+
});
39+
40+
var Thumbnail = React.createClass({displayName: "Thumbnail",
41+
render: function() {
42+
return React.createElement("div", {className: "col-sm-6 col-md-4"},
43+
React.createElement("div", {className: "thumbnail"},
44+
React.createElement("img", {src: this.props.imageUrl, alt: "..."}),
45+
React.createElement("div", {className: "caption"},
46+
React.createElement("h3", null, this.props.header),
47+
React.createElement("p", null, this.props.description),
48+
React.createElement("p", null,
49+
React.createElement(Badge, {title: this.props.title, number: this.props.number})
50+
)
51+
)
52+
)
53+
)
54+
}
55+
});

todos/gulpfile.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
var gulp = require('gulp');
2+
var gutil = require('gulp-util');
3+
var source = require('vinyl-source-stream');
4+
var browserify = require('browserify');
5+
var watchify = require('watchify');
6+
var reactify = require('reactify');
7+
var notifier = require('node-notifier');
8+
var server = require('gulp-server-livereload');
9+
10+
var notify = function(error) {
11+
var message = 'In: ';
12+
var title = 'Error: ';
13+
14+
if(error.description) {
15+
title += error.description;
16+
} else if (error.message) {
17+
title += error.message;
18+
}
19+
20+
if(error.filename) {
21+
var file = error.filename.split('/');
22+
message += file[file.length-1];
23+
}
24+
25+
if(error.lineNumber) {
26+
message += '\nOn Line: ' + error.lineNumber;
27+
}
28+
29+
notifier.notify({title: title, message: message});
30+
};
31+
32+
var bundler = watchify(browserify({
33+
entries: ['./src/app.jsx'],
34+
transform: [reactify],
35+
extensions: ['.jsx'],
36+
debug: true,
37+
cache: {},
38+
packageCache: {},
39+
fullPaths: true
40+
}));
41+
42+
function bundle() {
43+
return bundler
44+
.bundle()
45+
.on('error', notify)
46+
.pipe(source('main.js'))
47+
.pipe(gulp.dest('./'))
48+
}
49+
bundler.on('update', bundle)
50+
51+
gulp.task('build', function() {
52+
bundle()
53+
});
54+
55+
gulp.task('serve', function(done) {
56+
gulp.src('')
57+
.pipe(server({
58+
livereload: {
59+
enable: true,
60+
filter: function(filePath, cb) {
61+
cb( /main.js/.test(filePath) )
62+
}
63+
},
64+
open: true
65+
}));
66+
});
67+
68+
gulp.task('default', ['build', 'serve']);

todos/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<head>
2+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
3+
</head>
4+
<body>
5+
<div class="container">
6+
</div>
7+
</body>
8+
<script src="main.js"></script>

todos/package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "react-starter",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"scripts": {
6+
"test": "echo \"Error: no test specified\" && exit 1"
7+
},
8+
"author": "",
9+
"license": "ISC",
10+
"dependencies": {
11+
"browserify": "^9.0.3",
12+
"firebase": "^2.2.6",
13+
"gulp": "^3.8.11",
14+
"gulp-concat": "^2.5.2",
15+
"gulp-react": "^3.0.1",
16+
"gulp-server-livereload": "^1.3.0",
17+
"gulp-util": "^3.0.4",
18+
"node-notifier": "^4.2.1",
19+
"react": "^0.13.1",
20+
"reactfire": "^0.4.0",
21+
"reactify": "^1.1.0",
22+
"vinyl-source-stream": "^1.1.0",
23+
"watchify": "^2.4.0"
24+
},
25+
"devDependencies": {}
26+
}

todos/src/app.jsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var React = require('react');
2+
3+
var App = React.createClass({
4+
render: function() {
5+
return <h1>
6+
Hello, React!
7+
</h1>
8+
}
9+
});
10+
11+
var element = React.createElement(App, {});
12+
React.render(element, document.querySelector('.container'));

0 commit comments

Comments
 (0)