Skip to content

Commit

Permalink
add missing files up to pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim authored and Tim committed Aug 28, 2016
1 parent 9c6978a commit 7512e59
Show file tree
Hide file tree
Showing 44 changed files with 22,070 additions and 8 deletions.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions Lesson 12 Webpack setup/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<head>
<meta charset="UTF-8">
<title>Document</title>
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.33/browser.js"></script>-->
<link rel="stylesheet" href="./style/style.css">
</head>
<body>
<div id="app"></div>
Expand Down
1 change: 1 addition & 0 deletions Lesson 12 Webpack setup/package.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"babel-preset-es2015": "6.6.0",
"babel-preset-react": "6.5.0",
"babel-preset-stage-1": "6.5.0",
"babel-standalone": "^6.7.7",
"react": "15.0.2",
"react-dom": "15.0.2",
"webpack": "1.13.0",
Expand Down
44 changes: 44 additions & 0 deletions Lesson 12 Webpack setup/src/components/babel-transformer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import * as Babel from 'babel-standalone';

export default class BabelTransformer extends React.Component {
constructor() {
super();
this.state = {
inputJSX: '/* Add your JSX here */',
outputJS: '',
error: ''
}
this.transformJSX = this.transformJSX.bind(this);
}

transformJSX(event) {
let code = event.target.value;
try {
this.setState({
outputJS: Babel.transform(code, { sourceMaps: true, presets: ['es2015', 'react'] }).code,
error: ''
});

console.log(this.state.outputJS);
}
catch(error) {
this.setState({error: error.message})
}
}
render() {

return (
<div>
<div className="container" >
<textarea onChange={this.transformJSX} defaultValue={this.state.inputJSX}></textarea>
<pre>
{this.state.outputJS}
</pre>

</div>
<footer>{this.state.error}</footer>
</div>
)
}
};
11 changes: 3 additions & 8 deletions Lesson 12 Webpack setup/src/index.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import React from 'react';
import ReactDOM from 'react-dom';

const Hello = () => {
return (
<div>Hello world!</div>
)
}
import BabelTransformer from './components/babel-transformer';

ReactDOM.render(
<Hello />,
<BabelTransformer />,
document.getElementById('app')
);
);
36 changes: 36 additions & 0 deletions Lesson 12 Webpack setup/style/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
body {
margin: 0;
padding: 0;
/*font-family: monospace;*/
}

footer {
display: block;
height: 10vh;
overflow: auto;
background-color: #f1f1f1;
color: #c7254e;
font-size: 28px;
padding: 20px;
box-sizing: border-box;
}

.container {
height: 90vh;
display: flex;
box-sizing: border-box;

}

pre, textarea {
width: 50%;
margin: 0;
padding: 10px;
color: #222;
overflow: scroll;
}


textarea:focus {
outline: 0;
}
3 changes: 3 additions & 0 deletions Lesson 12 Webpack setup/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ module.exports = {
exclude: /node_modules/,
loader: 'babel'
}]
},
resolve: {
extensions: ['', '.js', '.jsx']
}
};
Loading

0 comments on commit 7512e59

Please sign in to comment.