Skip to content

Commit 864fd28

Browse files
committed
Initial commit
0 parents  commit 864fd28

22 files changed

+693
-0
lines changed

.bithoundrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"ignore": [
3+
"dist/*.js"
4+
]
5+
}

.editorconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
8+
[*]
9+
10+
# Change these settings to your own preference
11+
indent_style = space
12+
indent_size = 2
13+
14+
# We recommend you to keep these unchanged
15+
end_of_line = lf
16+
charset = utf-8
17+
trim_trailing_whitespace = true
18+
insert_final_newline = true
19+
20+
[*.md]
21+
trim_trailing_whitespace = false

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
gh-pages/
2+
dist-modules/
3+
dist/
4+

.eslintrc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"parser": "babel-eslint",
3+
"env": {
4+
"browser": true,
5+
"node": true,
6+
"jasmine": true
7+
},
8+
"plugins": [
9+
"react"
10+
],
11+
"globals": {
12+
"jest": false
13+
},
14+
"ecmaFeatures": {
15+
"jsx": true,
16+
"globalReturn": false
17+
},
18+
"rules": {
19+
"no-underscore-dangle": 0,
20+
"no-use-before-define": 0,
21+
"quotes": [2, "single"],
22+
"comma-dangle": 0,
23+
"react/jsx-boolean-value": 1,
24+
"react/jsx-quotes": 1,
25+
"react/jsx-no-undef": 1,
26+
"react/jsx-sort-props": 1,
27+
"react/jsx-uses-react": 1,
28+
"react/jsx-uses-vars": 1,
29+
"react/no-did-mount-set-state": 1,
30+
"react/no-did-update-set-state": 1,
31+
"react/no-multi-comp": 1,
32+
"react/no-unknown-property": 1,
33+
"react/prop-types": 1,
34+
"react/react-in-jsx-scope": 1,
35+
"react/self-closing-comp": 1,
36+
"react/wrap-multilines": 1
37+
}
38+
}

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
gh-pages/
2+
node_modules
3+
*.log
4+
.DS_Store

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language: node_js
2+
node_js:
3+
- "0.10"
4+
- "0.12"

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2015 Juho Vepsalainen
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[![build status](https://secure.travis-ci.org/bebraw/react-component-boilerplate.png)](http://travis-ci.org/bebraw/react-component-boilerplate) [![bitHound Score](https://www.bithound.io/github/bebraw/react-component-boilerplate/badges/score.svg)](https://www.bithound.io/github/bebraw/react-component-boilerplate) [![Dependency Status](https://david-dm.org/bebraw/react-component-boilerplate.svg)](https://david-dm.org/bebraw/react-component-boilerplate)
2+
# react-component-boilerplate - Boilerplate for React.js components
3+
4+
This is a simple boilerplate that has been developed to make it easier to develop React components. Check out [SurviveJS - Webpack and React](http://bebraw.com/) to dig deeper into the topic.
5+
6+
> IMPORTANT! If you use Jest for testing and rely on **react/addons**, you should depend on that at */src*. Otherwise you might end up getting mysterious failures when running tests at Travis. If this isn't done, test and library code end up using different instances of React and you will get failures!
7+
8+
## Basic Usage
9+
10+
* Replacing meta information - **npm run replace-meta** - This will allow you to update project metadata (GitHub user/project). Note that this can be potentially dangerous since it does just a naive search/replace over *README.md* and *package.json*!
11+
* Linting - **npm run lint**
12+
* Testing - **npm test** - This will lint too.
13+
* Developing - **npm start** - This will run a server at *localhost:3000* and use Hot Module Reloading.
14+
* Demo deployment - **npm run gh-pages** and **npm run deploy-gh-pages** - Demo will contain *README.md* by default and comes with simple styling based on Pure.
15+
* Generating a distribution version - **npm run dist-all** - This will generate `/dist` (UMD bundle + minified UMD bundle) and `/dist-modules`. Latter contains a version of `/src` that has been run through babel. It is meant for NPM users.
16+
17+
Note that there are hooks for `npm version`. The system will run tests, generate a distribution bundle and include that into the version commit. This can fail in case dist doesn't contain any changes! After that has completed it will generate GitHub Pages and deploy a new version.
18+
19+
```js
20+
var a = 5;
21+
var b = 10;
22+
23+
// just trying out code highlighting feature here
24+
console.log(a + b);
25+
```
26+
27+
## License
28+
29+
react-component-boilerplate is available under MIT. See LICENSE for more details.
30+

__tests__/boilerplate-test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
//var React = require('react/addons');
4+
//var TestUtils = React.addons.TestUtils;
5+
6+
describe('Boilerplate', function() {
7+
it('should do boilerplate things', function() {
8+
// TODO: test something now
9+
expect(true).toEqual(true);
10+
});
11+
});

demo/app.jsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from 'react';
2+
import Fork from 'react-ghfork';
3+
4+
import readme from '../README.md';
5+
import pkgInfo from '../package.json';
6+
7+
export default class App extends React.Component {
8+
render() {
9+
return (
10+
<div className='pure-g'>
11+
<Fork className='right' project={pkgInfo.user + '/' + pkgInfo.name} />
12+
<header className='pure-u-1'>
13+
<h1>{pkgInfo.name}</h1>
14+
15+
<div className='description'>{pkgInfo.description}</div>
16+
</header>
17+
<article className='pure-u-1'>
18+
<section className='demonstration'>
19+
<div className='description'>
20+
<h2>Demonstration</h2>
21+
22+
<p>Just demonstrating the awesomeness of this boilerplate here.</p>
23+
</div>
24+
25+
<div>...</div>
26+
</section>
27+
<section className='documentation'>
28+
<h2>README</h2>
29+
30+
<div dangerouslySetInnerHTML={{__html: readme}}></div>
31+
</section>
32+
</article>
33+
</div>
34+
);
35+
}
36+
};

demo/images/bgnoise_lg.png

5.3 KB
Loading

demo/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import 'purecss';
2+
import 'highlight.js/styles/github.css';
3+
import 'react-ghfork/gh-fork-ribbon.css';
4+
import './main.css';
5+
import '../style.css';
6+
7+
import React from 'react';
8+
import App from './app.jsx';
9+
10+
main();
11+
12+
function main() {
13+
var app = document.createElement('div');
14+
document.body.appendChild(app);
15+
16+
React.render(<App />, app);
17+
}

demo/main.css

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/* TODO: insert main styles of your demo here */
2+
3+
body {
4+
background: #fefefe;
5+
6+
font-family: Sans-Serif;
7+
8+
line-height: 1.5;
9+
}
10+
11+
form label {
12+
display: block;
13+
}
14+
15+
header {
16+
position: fixed;
17+
padding: 0.5em;
18+
top: 0;
19+
20+
text-align: center;
21+
22+
color: #333;
23+
border: 0.1em solid #bbb;
24+
25+
background-image: url(./images/bgnoise_lg.png);
26+
}
27+
28+
header h1 {
29+
margin: 0;
30+
}
31+
32+
header .description {
33+
color: #888;
34+
}
35+
36+
.highlight {
37+
background: rgb(255, 255, 175);
38+
}
39+
40+
.sticky {
41+
position: fixed;
42+
top: 0;
43+
left: 0;
44+
right: 0;
45+
}
46+
47+
.github-fork-ribbon {
48+
position: fixed;
49+
50+
letter-spacing: 0.01em;
51+
}
52+
53+
article {
54+
display: block !important;
55+
56+
margin-top: 6em;
57+
margin-left: auto;
58+
margin-right: auto;
59+
60+
max-width: 768px;
61+
}
62+
63+
article section {
64+
margin-bottom: 2em;
65+
}
66+
67+
article h2 {
68+
margin-top: 2em;
69+
}
70+
71+
pre {
72+
background: #fafefe;
73+
padding: 0.5em;
74+
}
75+
76+
article .description {
77+
margin: 1em;
78+
padding: 1em;
79+
80+
max-width: 60em;
81+
82+
background: #fafafa;
83+
84+
border: 0.1em solid #eee;
85+
}
86+
87+
article .description h2 {
88+
margin: 0;
89+
}

lib/deploy_gh_pages.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
var ghpages = require('gh-pages');
4+
5+
var config = require('../webpack.config');
6+
7+
main();
8+
9+
function main() {
10+
ghpages.publish(config.output.path, console.error.bind(console));
11+
}

lib/dev_server.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
var webpack = require('webpack');
3+
var WebpackDevServer = require('webpack-dev-server');
4+
5+
var config = require('../webpack.config');
6+
7+
new WebpackDevServer(webpack(config), {
8+
contentBase: __dirname,
9+
hot: true,
10+
historyApiFallback: true,
11+
stats: {
12+
colors: true
13+
},
14+
}).listen(config.port, config.ip, function(err) {
15+
if (err) {
16+
return console.log(err);
17+
}
18+
19+
console.log('Listening at ' + config.ip + ':' + config.port);
20+
});

lib/preprocessor.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
var ReactTools = require('react-tools');
4+
5+
module.exports = {
6+
process: function(src) {
7+
return ReactTools.transform(src, {
8+
harmony: true
9+
});
10+
}
11+
};

0 commit comments

Comments
 (0)