Created
February 15, 2017 05:57
-
-
Save edinsoncs/6d2ac253e264c6551553b1f54e781738 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"> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css" /> | |
<title>Facebook Like - React</title> | |
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> | |
<style> | |
body { | |
font-family: 'Roboto', sans-serif; | |
} | |
#main { | |
padding-top: 10em; | |
} | |
.c12 { | |
width: 80%; | |
margin: 0 auto; | |
} | |
.c4 { | |
width: 20%; | |
margin: 0 auto; | |
} | |
.card { | |
border-radius: 4px; | |
background-color: white; | |
box-shadow: 0 9px 7px rgba(0, 0, 0, 0.34); | |
padding: 0.5em; | |
} | |
.card .header__Card{ | |
background: url('https://scontent-eze1-1.xx.fbcdn.net/v/t31.0-8/14188248_1353723574658388_5109442472293940880_o.jpg?oh=fdc159b1c32614adf28ab7c813ee902f&oe=59372FE0'); | |
background-size: cover; | |
height: 80px; | |
position: relative; | |
text-align: center; | |
} | |
.card .header__Card .buttonLike { | |
background-color: #ededed; | |
position: absolute; | |
left: 0; | |
right: 0; | |
bottom: 0; | |
font-size: 0.9em; | |
padding: 0.2em; | |
} | |
.card .number { | |
text-align: center; | |
cursor: pointer; | |
} | |
</style> | |
</head> | |
<body> | |
<main id="main"> | |
<div class="c12"> | |
<div class="card c4"> | |
<header class="header__Card"> | |
<div class="buttonLike"> | |
Fang Pague React | |
</div> | |
</header> | |
<div class="number" id="toLike"> | |
</div> | |
</div> | |
</div> | |
</main> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react-dom.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.22.1/babel.min.js"></script> | |
<script type="text/babel"> | |
class Like extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
count: 0, | |
}; | |
this.handleClick = this.handleClick.bind(this); | |
} | |
handleClick(){ | |
this.setState({ | |
count: this.state.count + 1, | |
}); | |
} | |
render(){ | |
return ( | |
<h1 id="numbersHO" onClick={this.handleClick} > | |
{this.state.count} Likes | |
</h1> | |
) | |
} | |
} | |
ReactDOM.render( | |
<Like name='0' />, | |
document.getElementById('toLike') | |
); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment