From 5fa5ee418a341b23a263341dd53331b06ff1fd8d Mon Sep 17 00:00:00 2001 From: Nathan Harrenstein Date: Mon, 21 Aug 2017 15:37:37 -0700 Subject: [PATCH] Add cowsay generator. --- lab-nathan/.babelrc | 3 + lab-nathan/.eslintignore | 6 ++ lab-nathan/.eslintrc | 23 ++++++ lab-nathan/.gitignore | 138 +++++++++++++++++++++++++++++++++ lab-nathan/README.md | 3 + lab-nathan/package.json | 30 +++++++ lab-nathan/src/index.html | 9 +++ lab-nathan/src/main.js | 67 ++++++++++++++++ lab-nathan/src/style/main.scss | 15 ++++ lab-nathan/webpack.config.js | 31 ++++++++ 10 files changed, 325 insertions(+) create mode 100644 lab-nathan/.babelrc create mode 100644 lab-nathan/.eslintignore create mode 100644 lab-nathan/.eslintrc create mode 100644 lab-nathan/.gitignore create mode 100644 lab-nathan/README.md create mode 100644 lab-nathan/package.json create mode 100644 lab-nathan/src/index.html create mode 100644 lab-nathan/src/main.js create mode 100644 lab-nathan/src/style/main.scss create mode 100644 lab-nathan/webpack.config.js diff --git a/lab-nathan/.babelrc b/lab-nathan/.babelrc new file mode 100644 index 0000000..3b5a1b4 --- /dev/null +++ b/lab-nathan/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015","react"] +} \ No newline at end of file diff --git a/lab-nathan/.eslintignore b/lab-nathan/.eslintignore new file mode 100644 index 0000000..c6abca4 --- /dev/null +++ b/lab-nathan/.eslintignore @@ -0,0 +1,6 @@ +**/node_modules/* +**/vendor/* +**/*.min.js +**/coverage/* +**/build/* +**/assets/* diff --git a/lab-nathan/.eslintrc b/lab-nathan/.eslintrc new file mode 100644 index 0000000..1bd5280 --- /dev/null +++ b/lab-nathan/.eslintrc @@ -0,0 +1,23 @@ +{ + "rules": { + "no-console": "off", + "indent": [ "error", 2 ], + "quotes": [ "error", "single" ], + "semi": ["error", "always"] + }, + "env": { + "es6": true, + "node": true, + "mocha": true, + "jasmine": true + }, + "parserOptions": { + "sourceType": "module", + "ecmaFeatures": { + "modules": true, + "experimentalObjectRestSpread": true, + "impliedStrict": true + } + }, + "extends": "eslint:recommended" +} diff --git a/lab-nathan/.gitignore b/lab-nathan/.gitignore new file mode 100644 index 0000000..115b88e --- /dev/null +++ b/lab-nathan/.gitignore @@ -0,0 +1,138 @@ +# Created by https://www.gitignore.io/api/osx,vim,node,macos,windows + +### macOS ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + + +### OSX ### + +# Icon must end with two \r + +# Thumbnails + +# Files that might appear in the root of a volume + +# Directories potentially created on remote AFP share + +### Vim ### +# swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-v][a-z] +[._]sw[a-p] +# session +Session.vim +# temporary +.netrwhist +*~ +# auto-generated tag files +tags + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.gitignore.io/api/osx,vim,node,macos,windows + +data diff --git a/lab-nathan/README.md b/lab-nathan/README.md new file mode 100644 index 0000000..6f454b7 --- /dev/null +++ b/lab-nathan/README.md @@ -0,0 +1,3 @@ +# Lorem Cowsay + +A cowsay + lorem ipsum generator built with React. \ No newline at end of file diff --git a/lab-nathan/package.json b/lab-nathan/package.json new file mode 100644 index 0000000..ab1f40b --- /dev/null +++ b/lab-nathan/package.json @@ -0,0 +1,30 @@ +{ + "name": "lab-nathan", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "build": "webpack", + "watch": "webpack-dev-server --inline --hot" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "babel-core": "^6.26.0", + "babel-loader": "^7.1.2", + "babel-preset-es2015": "^6.24.1", + "babel-preset-react": "^6.24.1", + "cowsay-browser": "^1.1.8", + "css-loader": "^0.28.5", + "extract-text-webpack-plugin": "^3.0.0", + "faker": "^4.1.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", + "webpack": "^3.5.5", + "webpack-dev-server": "^2.7.1" + } +} diff --git a/lab-nathan/src/index.html b/lab-nathan/src/index.html new file mode 100644 index 0000000..c0ad003 --- /dev/null +++ b/lab-nathan/src/index.html @@ -0,0 +1,9 @@ + + + + Cow Say + + +
+ + \ No newline at end of file diff --git a/lab-nathan/src/main.js b/lab-nathan/src/main.js new file mode 100644 index 0000000..0d32a27 --- /dev/null +++ b/lab-nathan/src/main.js @@ -0,0 +1,67 @@ +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); + let ipsum = faker.lorem.sentence(); + this.state = { + ipsum: ipsum, + content: cowsay.say({ + text: ipsum + }), + cow: 'default' + }; + this.handleClick = this.handleClick.bind(this); + this.handleSelectionChange = this.handleSelectionChange.bind(this); + } + + handleClick(e) { + let ipsum = faker.lorem.sentence(); + this.setState(state => { + return { + ipsum: ipsum, + content: cowsay.say({ + text: ipsum, + f: this.state.cow + }), + }; + }); + } + + handleSelectionChange(e) { + let cow = document.getElementById('cows').value; + + this.setState(state => { + return { + content: cowsay.say({ + text: this.state.ipsum, + f: cow + }), + cow: cow + }; + }); + } + + render() { + let cowOptions; + + cowsay.list((error, cows) => { + cowOptions = cows.map(cow => ); + }); + + return ( +
+

Generate Cowsay Lorem

+ + +
{this.state.content}
+
+ ); + } +} + +ReactDom.render(, document.getElementById('root')); \ No newline at end of file diff --git a/lab-nathan/src/style/main.scss b/lab-nathan/src/style/main.scss new file mode 100644 index 0000000..84d720f --- /dev/null +++ b/lab-nathan/src/style/main.scss @@ -0,0 +1,15 @@ +body { + background: #def; +} + +#root { + text-align: center; +} + +select { + height: 30px; +} + +button { + height: 30px; +} \ No newline at end of file diff --git a/lab-nathan/webpack.config.js b/lab-nathan/webpack.config.js new file mode 100644 index 0000000..201e534 --- /dev/null +++ b/lab-nathan/webpack.config.js @@ -0,0 +1,31 @@ +'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