diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..facd180 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015", "react"] +} \ No newline at end of file diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..b663d77 --- /dev/null +++ b/.eslintrc @@ -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" +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/package.json b/package.json new file mode 100644 index 0000000..2405fcb --- /dev/null +++ b/package.json @@ -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" + } +} diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..02ebfec --- /dev/null +++ b/src/index.html @@ -0,0 +1,9 @@ + + + + Cowsay Lorem + + +
+ + diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..8b3fca4 --- /dev/null +++ b/src/main.js @@ -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 ( +
+
+

Generate Cowsay Lorem

+
+ +
{this.state.cowsay}
+
+ ) + } +} + +ReactDom.render(, document.getElementById('root')); \ No newline at end of file diff --git a/src/style/main.scss b/src/style/main.scss new file mode 100644 index 0000000..404685e --- /dev/null +++ b/src/style/main.scss @@ -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; +} \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..db50485 --- /dev/null +++ b/webpack.config.js @@ -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']) + } + ] + } +}; \ No newline at end of file