Created
June 28, 2018 13:19
-
-
Save SaraVieira/7809ba8bf8ce9c52a3930ad4ea02c9f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
</head> | |
<body> | |
<style> | |
html, | |
body, | |
#app { | |
margin: 0; | |
padding: 0; | |
background: #001f3f; | |
height: 100%; | |
color: white; | |
} | |
input { | |
height: 40px; | |
padding: 8px 10px; | |
border: none; | |
width: 200px; | |
margin: 10px 0; | |
font-size: 18px; | |
color: #111111; | |
} | |
.wrapper { | |
width: 100%; | |
height: 100%; | |
display: flex; | |
flex-direction: column; | |
font-family: Avenir, Arial, Helvetica, sans-serif; | |
font-size: 60px; | |
align-items: center; | |
justify-content: center; | |
} | |
.label { | |
font-size: 14px; | |
} | |
</style> | |
<div id="app"></div> | |
<!-- Note: when deploying, replace "development.js" with "production.min.js". --> | |
<script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script> | |
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script> | |
<script> | |
class Wrapper extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { text: '' }; | |
this.updateText = this.updateText.bind(this) | |
} | |
updateText(value) { | |
this.setState({ | |
text: value | |
}) | |
} | |
render() { | |
return React.createElement( | |
'div', | |
{ className: 'wrapper' }, | |
'Fill in the input', | |
Input({ updateText: this.updateText }), | |
Label({ text: this.state.text }) | |
); | |
} | |
} | |
function Input({ updateText }) { | |
return React.createElement( | |
'input', | |
{ | |
onChange: (e) => updateText(e.target.value), | |
placeholder: "Type here and watch the label change" | |
}, | |
); | |
} | |
function Label({ text }) { | |
return React.createElement( | |
'label', | |
{ className: 'label' }, | |
text | |
); | |
} | |
var container = document.querySelector('#app'); | |
ReactDOM.render( | |
React.createElement(Wrapper), | |
container | |
); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment