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 lab-nathan/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015","react"]
}
6 changes: 6 additions & 0 deletions lab-nathan/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/node_modules/*
**/vendor/*
**/*.min.js
**/coverage/*
**/build/*
**/assets/*
23 changes: 23 additions & 0 deletions lab-nathan/.eslintrc
Original file line number Diff line number Diff line change
@@ -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"
}
138 changes: 138 additions & 0 deletions lab-nathan/.gitignore
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions lab-nathan/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Lorem Cowsay

A cowsay + lorem ipsum generator built with React.
30 changes: 30 additions & 0 deletions lab-nathan/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
9 changes: 9 additions & 0 deletions lab-nathan/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>Cow Say</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
67 changes: 67 additions & 0 deletions lab-nathan/src/main.js
Original file line number Diff line number Diff line change
@@ -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 => <option value={cow}>{cow}</option>);
});

return (
<div>
<h1>Generate Cowsay Lorem</h1>
<select id="cows" defaultValue="default" onChange={this.handleSelectionChange}>{cowOptions}</select>
<button onClick={this.handleClick}>generate</button>
<pre>{this.state.content}</pre>
</div>
);
}
}

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

#root {
text-align: center;
}

select {
height: 30px;
}

button {
height: 30px;
}
31 changes: 31 additions & 0 deletions lab-nathan/webpack.config.js
Original file line number Diff line number Diff line change
@@ -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'])
}
]
}
};