Last active
November 4, 2015 18:53
-
-
Save ColeTownsend/f8a44b64ecac7a947a34 to your computer and use it in GitHub Desktop.
Latest Dribbble Shot (React)
This file contains 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
var UserShot = React.createClass({ | |
getInitialState: function() { | |
return { | |
username:'', | |
shots_url: '' | |
}; | |
}, | |
componentDidMount: function() { | |
var request = this.props.source += "?access_token=033e70302c4f5419b68d4e9b14f638c01b90245f989ad2c0ab0c1a4c7668352f"; | |
$.get(request, function(result) { | |
var lastShot = result[0]; | |
if (this.isMounted()) { | |
this.setState({ | |
username: this.props.username, | |
shotTitle: lastShot.title, | |
shotRetina: lastShot.images.hidpi, | |
shotDefault: lastShot.images.normal, | |
shotLikes: lastShot.likes_count | |
}); | |
} | |
}.bind(this)); | |
}, | |
render: function() { | |
return ( | |
<div className="dribbble-card"> | |
<img src={this.state.shotRetina} /> | |
<header className="shot-data"> | |
<h5 className="shot-title">{this.state.shotTitle}</h5> | |
<h5 className="shot-likes">{this.state.shotLikes}</h5> | |
</header> | |
</div> | |
); | |
} | |
}); | |
React.render( | |
<UserShot source="https://api.dribbble.com/v1/users/coletownsend/shots/" />, | |
document.body | |
) |
This file contains 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> | |
<head> | |
<script src="//fb.me/react-0.13.3.js"></script> | |
<script src="https://code.jquery.com/jquery-1.6.4.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<style> | |
body { | |
font-family: "SF UI Text"; | |
font-size: 14px; | |
background: #f9f9f9; | |
} | |
h1,h2,h3,h4,h5 { | |
margin: 0; | |
} | |
.dribbble-card { | |
max-width: 240px; | |
display: flex; | |
flex-direction:column; | |
padding: 1rem; | |
background: white; | |
border-radius: 2px; | |
box-shadow: 0 1px 2px rgba(0,0,0,.05) ; | |
} | |
.dribbble-card .shot-data { | |
display: flex; | |
justify-content: space-between; | |
padding-top: 1rem; | |
} | |
.shot-title { | |
text-transform: uppercase; | |
font-weight: normal; | |
letter-spacing: 1px; | |
color: | |
} | |
.shot-likes { | |
color: #DD6A6E; | |
position: relative; | |
padding-right: 16px; | |
} | |
.shot-likes::after { | |
position: absolute; | |
color: #DD6A6E; | |
content: '❤'; | |
right: 0; | |
top: 0; | |
display: block; | |
} | |
img { | |
width: 100%; | |
height: auto; | |
flex: none; | |
} | |
</style> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment