Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015", "react"]
}
21 changes: 21 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"rules": {
"no-console": "off",
"indent": [ "error", 2 ],
"quotes": [ "error", "single" ],
"semi": ["error", "always"],
"linebreak-style": [ "error", "unix" ]
},
"env": {
"es6": true,
"node": true,
"mocha": true,
"jasmine": true
},
"ecmaFeatures": {
"modules": true,
"experimentalObjectRestSpread": true,
"impliedStrict": true
},
"extends": "eslint:recommended"
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
37 changes: 37 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "21-react-tooling",
"version": "1.0.0",
"description": "![cf](https://i.imgur.com/7v5ASc8.png) 21: React Tooling ======",
"main": "index.js",
"scripts": {
"build": "webpack",
"watch": "webpack-dev-server --inline --hot"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Loaye/21-react-tooling.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/Loaye/21-react-tooling/issues"
},
"homepage": "https://github.com/Loaye/21-react-tooling#readme",
"dependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.5",
"extract-text-webpack-plugin": "^3.0.0",
"html-webpack-plugin": "^2.30.1",
"node-sass": "^4.5.3",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"sass-loader": "^6.0.6",
"superagent": "^3.6.0",
"webpack": "^3.5.5",
"webpack-dev-server": "^2.7.1"
}
}
9 changes: 9 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>Cowsay Lorem</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
38 changes: 38 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import './style/main.scss';
import React from 'react';
import ReactDom from 'react-dom';
import cowsay from 'cowsay-browser';
import faker from 'faker';

class App extends React.Component {
constructor(props) {
super(props);
this.state = {
cowsay: cowsay.say({ text: 'I\'m a cow' })
};

this.handleClick = this.handleClick.bind(this);
}

handleClick(e) {
this.setState(state => {
return {
cowsay: cowsay.say({ text: faker.lorem.words(10) })
}
});
}

render() {
return (
<div>
<header>
<h1>Generate Cowsay Lorem</h1>
</header>
<button onClick={this.handleClick}>Click Me!</button>
<pre>{this.state.cowsay}</pre>
</div>
)
}
}

ReactDom.render(<App />, document.getElementById('root'));
19 changes: 19 additions & 0 deletions src/style/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
body {
background: black;
}

h1, pre {
color: white;
}

h1, button {
font-family: Georgia
}

button {
border: none;
border-radius: 5px;
background: white;
padding: 5px 3px;
color: green;
}
32 changes: 32 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

'use strict';

const HtmlPlugin = require('html-webpack-plugin');
const ExtractPlugin = require('extract-text-webpack-plugin');

module.exports = {
devtool: 'cheap-module-eval-source-map',
entry: `${__dirname}/src/main.js`,
output: {
path: `${__dirname}/build`,
publicPath: '/',
filename: 'bundle-[hash].js'
},
plugins: [
new HtmlPlugin({ template: `${__dirname}/src/index.html`}),
new ExtractPlugin('bundle-[hash].css')
],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.scss$/,
loader: ExtractPlugin.extract(['css-loader', 'sass-loader'])
}
]
}
};