From 293577e41188d5586fe043dc20709693a1b62558 Mon Sep 17 00:00:00 2001 From: andyfiveeleven Date: Mon, 28 Aug 2017 09:10:05 -0700 Subject: [PATCH 1/2] got back super late last night from weeok in teh woods, this works but isnt styled. will style today --- original 24 | 1 + 1 file changed, 1 insertion(+) create mode 160000 original 24 diff --git a/original 24 b/original 24 new file mode 160000 index 0000000..ea43737 --- /dev/null +++ b/original 24 @@ -0,0 +1 @@ +Subproject commit ea43737fdc4dd054240cfa23c810b4b244b4c362 From 3c33be658d5d6caa35627b7e887dd8fa5e390102 Mon Sep 17 00:00:00 2001 From: andyfiveeleven Date: Mon, 28 Aug 2017 09:12:28 -0700 Subject: [PATCH 2/2] dir name change --- original 24 | 1 - original-24/.babelrc | 3 + original-24/.eslintrc | 21 ++++++ original-24/.gitignore | 70 +++++++++++++++++++ original-24/README.md | 0 original-24/package.json | 38 ++++++++++ original-24/src/.babelrc | 3 + original-24/src/.eslintrc | 21 ++++++ original-24/src/.gitignore | 70 +++++++++++++++++++ .../src/component/note-container/index.js | 60 ++++++++++++++++ .../src/component/note-create-form/index.js | 51 ++++++++++++++ original-24/src/component/note-list/index.js | 60 ++++++++++++++++ .../src/component/note-update-form/index.js | 46 ++++++++++++ original-24/src/index.html | 10 +++ original-24/src/main.js | 45 ++++++++++++ original-24/src/style/main.scss | 14 ++++ original-24/webpack.config.js | 34 +++++++++ 17 files changed, 546 insertions(+), 1 deletion(-) delete mode 160000 original 24 create mode 100644 original-24/.babelrc create mode 100644 original-24/.eslintrc create mode 100644 original-24/.gitignore create mode 100644 original-24/README.md create mode 100644 original-24/package.json create mode 100644 original-24/src/.babelrc create mode 100644 original-24/src/.eslintrc create mode 100644 original-24/src/.gitignore create mode 100644 original-24/src/component/note-container/index.js create mode 100644 original-24/src/component/note-create-form/index.js create mode 100644 original-24/src/component/note-list/index.js create mode 100644 original-24/src/component/note-update-form/index.js create mode 100644 original-24/src/index.html create mode 100644 original-24/src/main.js create mode 100644 original-24/src/style/main.scss create mode 100644 original-24/webpack.config.js diff --git a/original 24 b/original 24 deleted file mode 160000 index ea43737..0000000 --- a/original 24 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ea43737fdc4dd054240cfa23c810b4b244b4c362 diff --git a/original-24/.babelrc b/original-24/.babelrc new file mode 100644 index 0000000..86c445f --- /dev/null +++ b/original-24/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015", "react"] +} diff --git a/original-24/.eslintrc b/original-24/.eslintrc new file mode 100644 index 0000000..8dc6807 --- /dev/null +++ b/original-24/.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/original-24/.gitignore b/original-24/.gitignore new file mode 100644 index 0000000..57bad08 --- /dev/null +++ b/original-24/.gitignore @@ -0,0 +1,70 @@ +# Created by https://www.gitignore.io/api/osx,linux,node,vim +node_modules +.env +.test.env +db/ +build/ + +.DS_Store +.AppleDouble +.LSOverride + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + + +### Node ### +# Logs +logs +*.log +npm-debug.log* +.tern-project + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history + +### Vim ### +# swap +[._]*.s[a-w][a-z] +[._]s[a-w][a-z] +# session +Session.vim +# temporary +.netrwhist +*~ + +# auto-generated tag files +tags diff --git a/original-24/README.md b/original-24/README.md new file mode 100644 index 0000000..e69de29 diff --git a/original-24/package.json b/original-24/package.json new file mode 100644 index 0000000..5a0f16c --- /dev/null +++ b/original-24/package.json @@ -0,0 +1,38 @@ +{ + "name": "23-components_and_routing", + "version": "1.0.0", + "description": "![cf](https://i.imgur.com/7v5ASc8.png) 23: Components and Routing ======", + "main": "index.js", + "scripts": { + "build": "webpack", + "watch": "webpack-dev-server --inline --hot" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/nickjaz/23-components_and_routing.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/nickjaz/23-components_and_routing/issues" + }, + "homepage": "https://github.com/nickjaz/23-components_and_routing#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", + "react-router-dom": "^4.1.2", + "sass-loader": "^6.0.6", + "uuid": "^3.1.0", + "webpack": "^3.5.5", + "webpack-dev-server": "^2.7.1" + } +} diff --git a/original-24/src/.babelrc b/original-24/src/.babelrc new file mode 100644 index 0000000..86c445f --- /dev/null +++ b/original-24/src/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015", "react"] +} diff --git a/original-24/src/.eslintrc b/original-24/src/.eslintrc new file mode 100644 index 0000000..8dc6807 --- /dev/null +++ b/original-24/src/.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/original-24/src/.gitignore b/original-24/src/.gitignore new file mode 100644 index 0000000..57bad08 --- /dev/null +++ b/original-24/src/.gitignore @@ -0,0 +1,70 @@ +# Created by https://www.gitignore.io/api/osx,linux,node,vim +node_modules +.env +.test.env +db/ +build/ + +.DS_Store +.AppleDouble +.LSOverride + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + + +### Node ### +# Logs +logs +*.log +npm-debug.log* +.tern-project + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history + +### Vim ### +# swap +[._]*.s[a-w][a-z] +[._]s[a-w][a-z] +# session +Session.vim +# temporary +.netrwhist +*~ + +# auto-generated tag files +tags diff --git a/original-24/src/component/note-container/index.js b/original-24/src/component/note-container/index.js new file mode 100644 index 0000000..127229e --- /dev/null +++ b/original-24/src/component/note-container/index.js @@ -0,0 +1,60 @@ +import React from 'react'; +import uuid from 'uuid/v1'; + +import NoteCreateForm from '../note-create-form'; +import NoteList from '../note-list' + +class NoteContainer extends React.Component { + constructor(props) { + super(props); + this.noteCreate = this.noteCreate.bind(this); + this.noteRemove = this.noteRemove.bind(this); + this.noteUpdate = this.noteUpdate.bind(this); + } + + noteCreate(note) { + note.id = uuid(); + this.props.app.setState(state => ({ + notes: [...state.notes, note] + })); + } + + noteRemove(note) { + let {app} = this.props; + app.setState(prevState => ({ + notes: prevState.notes.filter((item) => { + return item.id !==note.id + }) + })); + } + + noteUpdate(note) { + let{app} = this.props; + app.setState(prevState => ({ + notes: prevState.notes.map((item) =>{ + return item.id === note.id ? note : item; + }) + })); + } + + render() { + let {app} =this.props; + + return ( + +
+ + +
+ ) + } +} + +export default NoteContainer; diff --git a/original-24/src/component/note-create-form/index.js b/original-24/src/component/note-create-form/index.js new file mode 100644 index 0000000..80c7fd2 --- /dev/null +++ b/original-24/src/component/note-create-form/index.js @@ -0,0 +1,51 @@ +import React from 'react'; + +class NoteCreateForm extends React.Component { + constructor(props) { + super(props); + this.state = { + title: '', + content: '', + // editing: false, + completed: false + } + this.handleChange = this.handleChange.bind(this); + this.handleSubmit = this.handleSubmit.bind(this); + } + + handleChange(e) { + this.setState({ + [e.target.name]: e.target.value + }) + } + + handleSubmit(e) { + e.preventDefault(); + this.props.handleSubmit(this.state); + } + + render() { + return ( +
+ + + +
+ ) + } +} + +export default NoteCreateForm; diff --git a/original-24/src/component/note-list/index.js b/original-24/src/component/note-list/index.js new file mode 100644 index 0000000..e8283c2 --- /dev/null +++ b/original-24/src/component/note-list/index.js @@ -0,0 +1,60 @@ +import React from 'react'; +import NoteUpdateForm from '../note-update-form'; + +let renderIf = (test, component) => test ? component :undefined; + +class NoteList extends React.Component { + constructor(props){ + super(props); + this.state = { + editing:false + } + + this.handleEditClick = this.handleEditClick.bind(this); + } + + handleEditClick(e){ + this.setState({ + editing: true + }) + } + //state editing = true + render() { + return ( +
+ { this.props.notes.length === 0 ? +
+

add a note

+
: +
    + {this.props.notes.map((item, i) => { + return ( +
  • + + +
    +

    {item.title}

    +

    {item.content}

    +
    + + {renderIf(this.state.editing, + { + note.id = item.id; + this.props.noteUpdate(note); + }} + /> + )} +
  • + ) + })} +
+ } +
+ ) + } +} + +export default NoteList; diff --git a/original-24/src/component/note-update-form/index.js b/original-24/src/component/note-update-form/index.js new file mode 100644 index 0000000..c46fe51 --- /dev/null +++ b/original-24/src/component/note-update-form/index.js @@ -0,0 +1,46 @@ +import React from 'react'; + +class NoteUpdateForm extends React.Component { + constructor(props) { + super(props); + + this.state = { + title: this.props.note.title, + content: '', + editing: false, + complete: false + } + + this.handleChange = this.handleChange.bind(this); + this.handleSubmit = this.handleSubmit.bind(this); + } + + handleChange(e) { + this.setState({ + [e.target.name]: e.target.value + }) + } + + handleSubmit(e) { + e.preventDefault(); + this.props.handleSubmit(this.state) + } + + + render() { + return( +
+ + + +
+ ) + } +} + +export default NoteUpdateForm diff --git a/original-24/src/index.html b/original-24/src/index.html new file mode 100644 index 0000000..3243af3 --- /dev/null +++ b/original-24/src/index.html @@ -0,0 +1,10 @@ + + + + + Note Maker App + + +
+ + diff --git a/original-24/src/main.js b/original-24/src/main.js new file mode 100644 index 0000000..429c9a4 --- /dev/null +++ b/original-24/src/main.js @@ -0,0 +1,45 @@ +import './style/main.scss'; +import React from 'react'; +import ReactDom from 'react-dom'; +import {BrowserRouter, Route} from 'react-router-dom'; + +import NoteContainer from './component/note-container'; + +class App extends React.Component { + constructor(props) { + super(props); + this.state = { + notes: [] + } + + this.getApp = this.getApp.bind(this); + } + + componentDidUpdate() { + console.log('__STATE__', this.state); + } + + getApp() { + return { + state: this.state, + setState: this.setState.bind(this) + } + } + + render() { + return ( +
+

Note Maker

+ +
+ + } /> +
+
+ +
+ ) + } +} + +ReactDom.render(, document.getElementById('root')) diff --git a/original-24/src/style/main.scss b/original-24/src/style/main.scss new file mode 100644 index 0000000..c6cf1c3 --- /dev/null +++ b/original-24/src/style/main.scss @@ -0,0 +1,14 @@ +main { + font-family: helvetica; +} + +input, button { + display: block; + margin: 4px auto; +} + +button { + border: none; + border-radius: 2px; + padding: 4px 8px; +} diff --git a/original-24/webpack.config.js b/original-24/webpack.config.js new file mode 100644 index 0000000..6a08720 --- /dev/null +++ b/original-24/webpack.config.js @@ -0,0 +1,34 @@ +'use strict'; + +const HtmlPlugin = require('html-webpack-plugin'); +const ExtractPlugin = require('extract-text-webpack-plugin'); + +module.exports = { + devtool: 'cheap-module-eval-source-map', + devServer: { + historyApiFallback: true + }, + entry: `${__dirname}/src/main.js`, + output: { + filename: 'bundle-[hash].js', + path: `${__dirname}/build`, + publicPath: '/' + }, + 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']) + } + ] + } +};