From 8cec913475eb0f768124cf964248dd8697be92d1 Mon Sep 17 00:00:00 2001 From: Eddie Date: Mon, 21 Aug 2017 14:29:38 -0700 Subject: [PATCH 1/9] Set up scaffolding --- lab-eddie/.babelrc | 0 lab-eddie/src/main.js | 0 lab-eddie/src/style/main.scss | 0 lab-eddie/webpack.config.js | 0 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 lab-eddie/.babelrc create mode 100644 lab-eddie/src/main.js create mode 100644 lab-eddie/src/style/main.scss create mode 100644 lab-eddie/webpack.config.js diff --git a/lab-eddie/.babelrc b/lab-eddie/.babelrc new file mode 100644 index 0000000..e69de29 diff --git a/lab-eddie/src/main.js b/lab-eddie/src/main.js new file mode 100644 index 0000000..e69de29 diff --git a/lab-eddie/src/style/main.scss b/lab-eddie/src/style/main.scss new file mode 100644 index 0000000..e69de29 diff --git a/lab-eddie/webpack.config.js b/lab-eddie/webpack.config.js new file mode 100644 index 0000000..e69de29 From 8972c2a17090d0339854bb60c96d595e58a9b8f9 Mon Sep 17 00:00:00 2001 From: Eddie Date: Mon, 21 Aug 2017 15:00:30 -0700 Subject: [PATCH 2/9] Installed npm dependancies, copied config files and created .babelrc file --- lab-eddie/.babelrc | 3 + lab-eddie/.eslintignore | 5 ++ lab-eddie/.eslintrc | 21 +++++++ lab-eddie/.gitignore | 136 ++++++++++++++++++++++++++++++++++++++++ lab-eddie/package.json | 29 +++++++++ 5 files changed, 194 insertions(+) create mode 100644 lab-eddie/.eslintignore create mode 100644 lab-eddie/.eslintrc create mode 100644 lab-eddie/.gitignore create mode 100644 lab-eddie/package.json diff --git a/lab-eddie/.babelrc b/lab-eddie/.babelrc index e69de29..86c445f 100644 --- a/lab-eddie/.babelrc +++ b/lab-eddie/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015", "react"] +} diff --git a/lab-eddie/.eslintignore b/lab-eddie/.eslintignore new file mode 100644 index 0000000..05b1cf3 --- /dev/null +++ b/lab-eddie/.eslintignore @@ -0,0 +1,5 @@ +**/node_modules/* +**/vendor/* +**/*.min.js +**/coverage/* +**/build/* diff --git a/lab-eddie/.eslintrc b/lab-eddie/.eslintrc new file mode 100644 index 0000000..8dc6807 --- /dev/null +++ b/lab-eddie/.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" +} diff --git a/lab-eddie/.gitignore b/lab-eddie/.gitignore new file mode 100644 index 0000000..345130c --- /dev/null +++ b/lab-eddie/.gitignore @@ -0,0 +1,136 @@ +# 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 diff --git a/lab-eddie/package.json b/lab-eddie/package.json new file mode 100644 index 0000000..5cb870b --- /dev/null +++ b/lab-eddie/package.json @@ -0,0 +1,29 @@ +{ + "name": "lab-eddie", + "version": "1.0.0", + "description": "", + "main": "webpack.config.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "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": "^1.1.9", + "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" + } +} From ab949076154e113086bae7af245fa94a0bc8aa2a Mon Sep 17 00:00:00 2001 From: Eddie Date: Mon, 21 Aug 2017 15:34:48 -0700 Subject: [PATCH 3/9] Wrote webpack script --- lab-eddie/webpack.config.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lab-eddie/webpack.config.js b/lab-eddie/webpack.config.js index e69de29..7db3ca2 100644 --- a/lab-eddie/webpack.config.js +++ b/lab-eddie/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`, + ouput: { + path: `${__dirname}/build`, + pathPublic: '/', + 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']) + } + ] + } +}; From 6df02b27751ade874834167deea598932bb7b9a8 Mon Sep 17 00:00:00 2001 From: Eddie Date: Mon, 21 Aug 2017 22:18:20 -0700 Subject: [PATCH 4/9] Got the cow to print out but he looks like he just came thorugh a blender --- lab-eddie/package.json | 5 ++- lab-eddie/src/index.html | 10 +++++ lab-eddie/src/main.js | 74 +++++++++++++++++++++++++++++++++++ lab-eddie/src/style/main.scss | 9 +++++ lab-eddie/webpack.config.js | 4 +- 5 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 lab-eddie/src/index.html diff --git a/lab-eddie/package.json b/lab-eddie/package.json index 5cb870b..113cc8f 100644 --- a/lab-eddie/package.json +++ b/lab-eddie/package.json @@ -4,7 +4,8 @@ "description": "", "main": "webpack.config.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "build": "webpack", + "watch": "webpack-dev-server --inline --hot" }, "keywords": [], "author": "", @@ -14,7 +15,7 @@ "babel-loader": "^7.1.2", "babel-preset-es2015": "^6.24.1", "babel-preset-react": "^6.24.1", - "cowsay": "^1.1.9", + "cowsay-browser": "^1.1.8", "css-loader": "^0.28.5", "extract-text-webpack-plugin": "^3.0.0", "faker": "^4.1.0", diff --git a/lab-eddie/src/index.html b/lab-eddie/src/index.html new file mode 100644 index 0000000..46e5932 --- /dev/null +++ b/lab-eddie/src/index.html @@ -0,0 +1,10 @@ + + + + + Cowsay App + + +
+ + diff --git a/lab-eddie/src/main.js b/lab-eddie/src/main.js index e69de29..ba44f2a 100644 --- a/lab-eddie/src/main.js +++ b/lab-eddie/src/main.js @@ -0,0 +1,74 @@ +import React from 'react'; +import ReactDom from 'react-dom'; +import './style/main.scss'; +import cowsay from 'cowsay-browser' +import faker from 'faker' + +class CowBody extends React.Component { + constructor(props) { + super(props); + + this.state = { + cow: '' + } + this.newIpsum = this.newIpsum.bind(this); + } + + newIpsum(e) { + let ipsum = faker.lorem.sentence(); + + this.setState(state => { + return { + cow: cowsay.think({ + text: ipsum + }) + } + }) + } + + render() { + return( +
+ +

{this.state.cow}

+
+ ) + } + + +} + +class CowHead extends React.Component { + constructor(props) { + super(props); + } + + render() { + return ( +
+

Gerate Cowsay Lorem

+
+ ); + } +} + +class App extends React.Component { + constructor(props) { + super(props); + } + render() { + return ( +
+ + +
+ ); + } +} + + + + + + +ReactDom.render(, document.getElementById('root')); diff --git a/lab-eddie/src/style/main.scss b/lab-eddie/src/style/main.scss index e69de29..83f81e3 100644 --- a/lab-eddie/src/style/main.scss +++ b/lab-eddie/src/style/main.scss @@ -0,0 +1,9 @@ +body { + background: green; +} + +p { + width: 15vw; + height: 15vh; + background: white; +} diff --git a/lab-eddie/webpack.config.js b/lab-eddie/webpack.config.js index 7db3ca2..aa96380 100644 --- a/lab-eddie/webpack.config.js +++ b/lab-eddie/webpack.config.js @@ -6,9 +6,9 @@ const ExtractPlugin = require('extract-text-webpack-plugin'); module.exports = { devtool: 'cheap=module-eval-source-map', entry: `${__dirname}/src/main.js`, - ouput: { + output: { path: `${__dirname}/build`, - pathPublic: '/', + publicPath: '/', filename: 'bundle-[hash].js' }, plugins: [ From 9f93c022cff443a6c4f476c301fb56cd94db108c Mon Sep 17 00:00:00 2001 From: Eddie Date: Mon, 21 Aug 2017 22:20:49 -0700 Subject: [PATCH 5/9] Added README file --- lab-eddie/README.MD | 1 + 1 file changed, 1 insertion(+) create mode 100644 lab-eddie/README.MD diff --git a/lab-eddie/README.MD b/lab-eddie/README.MD new file mode 100644 index 0000000..7b7fc14 --- /dev/null +++ b/lab-eddie/README.MD @@ -0,0 +1 @@ +This is my first react lab. I could immediately see how useful this framework is going to be From 340eb176586348ab3596dcad046b9c7ed5f9538c Mon Sep 17 00:00:00 2001 From: Eddie Date: Mon, 21 Aug 2017 23:07:53 -0700 Subject: [PATCH 6/9] Changed p tag to pre tag --- lab-eddie/src/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lab-eddie/src/main.js b/lab-eddie/src/main.js index ba44f2a..c3ff56d 100644 --- a/lab-eddie/src/main.js +++ b/lab-eddie/src/main.js @@ -30,7 +30,7 @@ class CowBody extends React.Component { return(
-

{this.state.cow}

+
{this.state.cow}
) } From a9a7f7c7fdb73d6a0d3505edab173ef03bbc57ff Mon Sep 17 00:00:00 2001 From: Eddie Date: Tue, 22 Aug 2017 09:05:09 -0700 Subject: [PATCH 7/9] Added some crappy styling --- lab-eddie/src/style/main.scss | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lab-eddie/src/style/main.scss b/lab-eddie/src/style/main.scss index 83f81e3..efe054e 100644 --- a/lab-eddie/src/style/main.scss +++ b/lab-eddie/src/style/main.scss @@ -2,8 +2,9 @@ body { background: green; } -p { - width: 15vw; - height: 15vh; +pre { + width: 80vw; + height: 30vh; background: white; + border-radius: 40px; } From ccf5d7f0412ebfedc6589c4d9663ed4e5f4a83ec Mon Sep 17 00:00:00 2001 From: Eddie Date: Tue, 22 Aug 2017 09:39:01 -0700 Subject: [PATCH 8/9] Fixed typo in webpack config file --- lab-eddie/webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lab-eddie/webpack.config.js b/lab-eddie/webpack.config.js index aa96380..0303f76 100644 --- a/lab-eddie/webpack.config.js +++ b/lab-eddie/webpack.config.js @@ -4,7 +4,7 @@ const HtmlPlugin = require('html-webpack-plugin'); const ExtractPlugin = require('extract-text-webpack-plugin'); module.exports = { - devtool: 'cheap=module-eval-source-map', + devtool: 'cheap-module-eval-source-map', entry: `${__dirname}/src/main.js`, output: { path: `${__dirname}/build`, From a47285909f2e4fd2ae3d45542b741e9a61a97fd9 Mon Sep 17 00:00:00 2001 From: Eddie Date: Tue, 22 Aug 2017 09:40:13 -0700 Subject: [PATCH 9/9] Deleted default README.MD --- README.md | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 53d20d9..0000000 --- a/README.md +++ /dev/null @@ -1,48 +0,0 @@ -![cf](https://i.imgur.com/7v5ASc8.png) 21: React Tooling -====== - -## Submission Instructions - * fork this repository & create a new branch for your work - * write all of your code in a directory named `lab-` + `` **e.g.** `lab-susan` - * push to your repository - * submit a pull request to this repository - * submit a link to your PR in canvas - * write a question and observation on canvas - - -## Learning Objectives -* students will be able to configure webpack.js to build a web application bundle -* students will be able to configure babel to transpile JSX and ES6 to ES5 JavaScript -* students will be able to create and render React components to the DOM -* students will be able to add event listeners to React components -* students will be able to update React component state - -## Requirements -#### Configuration -* `README.md` -* `.gitignore` -* `.eslintrc` -* `.babelrc` -* `package.json` -* `webpack.config.js` -* `src/**` - * `src/main.js` - * `src/style` - * `src/style/main.scss` - -#### Feature Tasks -* create the following component: -###### App -* should contain the entire application's view and state -* should have a property on the state called `content` -* should create a view with the following display - * a heading with the title "Generate Cowsay Lorem" - * a button that displays "click me" - * `onClick` the button should generate new content on the app state using `cowsay` and `faker` - * a `pre` tag that displays the app's state's content - -#### Documentation -* write a brief description of your project in `README.md` - -#### Bonus 1pt -* add a select menu that enables you to change the type of cowfile currently being used