web: CodeArea

This commit is contained in:
greg 2017-09-20 23:46:46 -07:00
parent 10b1864680
commit d4aec19c71
2 changed files with 28 additions and 5 deletions

View File

@ -5,10 +5,6 @@
<body> <body>
<div id="main"> <div id="main">
</div> </div>
Type your source code into here:
<textarea class="code-input">
</textarea>
<script src="bundle.js"></script> <script src="bundle.js"></script>
</body> </body>
</html> </html>

View File

@ -1,10 +1,37 @@
const React = require("react"); const React = require("react");
const ReactDOM = require("react-dom"); const ReactDOM = require("react-dom");
class CodeArea extends React.Component {
constructor(props) {
super(props);
this.state = {value: ""};
this.handleChange = this.handleChange.bind(this);
this.submit = this.submit.bind(this);
}
handleChange(event) {
this.setState({value: event.target.value});
}
submit(event) {
console.log("This", this.state.value);
}
render() {
return (<div>
<textarea value={ this.state.value } onChange={this.handleChange}>
</textarea>
<button onClick={ this.submit }>Run!</button>
</div>);
}
}
const main = (<div> const main = (<div>
<h1>Schala web input</h1> <h1>Schala web input</h1>
<p>Write your source code here</p> <p>Write your source code here</p>
<CodeArea/>
</div>); </div>);
const rootDom = document.getElementById("main"); const rootDom = document.getElementById("main");
ReactDOM.render(<h1>Schala web input</h1>, rootDom); ReactDOM.render(main, rootDom);