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 original-24/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015", "react"]
}
21 changes: 21 additions & 0 deletions original-24/.eslintrc
Original file line number Diff line number Diff line change
@@ -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"
}
70 changes: 70 additions & 0 deletions original-24/.gitignore
Original file line number Diff line number Diff line change
@@ -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
Empty file added original-24/README.md
Empty file.
38 changes: 38 additions & 0 deletions original-24/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
3 changes: 3 additions & 0 deletions original-24/src/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015", "react"]
}
21 changes: 21 additions & 0 deletions original-24/src/.eslintrc
Original file line number Diff line number Diff line change
@@ -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"
}
70 changes: 70 additions & 0 deletions original-24/src/.gitignore
Original file line number Diff line number Diff line change
@@ -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
60 changes: 60 additions & 0 deletions original-24/src/component/note-container/index.js
Original file line number Diff line number Diff line change
@@ -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 (

<div className='note-container'>
<NoteCreateForm
handleSubmit={this.noteCreate}
subitTitle='add note'
/>
<NoteList
notes={app.state.notes}
noteRemove={this.noteRemove}
noteUpdate={this.noteUpdate}
/>
</div>
)
}
}

export default NoteContainer;
51 changes: 51 additions & 0 deletions original-24/src/component/note-create-form/index.js
Original file line number Diff line number Diff line change
@@ -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 (
<form onSubmit={this.handleSubmit}>
<input
name='title'
type='text'
placeholder='title'
value={this.state.title}
onChange={this.handleChange}
/>
<input
className='note-content'
name='content'
type='text'
placeholder='enter note content here'
value={this.state.content}
onChange={this.handleChange}
/>
<button type='submit'>Add</button>
</form>
)
}
}

export default NoteCreateForm;
Loading