Skip to content

Instantly share code, notes, and snippets.

@tomodutch
Last active September 12, 2015 12:47
Show Gist options
  • Save tomodutch/d2cb2d9f47815d0df87e to your computer and use it in GitHub Desktop.
Save tomodutch/d2cb2d9f47815d0df87e to your computer and use it in GitHub Desktop.
<dom-module id="github-card">
<style>
</style>
<template>
<iron-ajax
id="getCard"
handle-as="json"
on-response="handleResponse">
</iron-ajax>
<div>
<paper-card heading="{{name}}" image="{{profile.avatar_url}}">
<div class="card-content">
Followers: <span>{{profile.followers}}</span>
Following: <span>{{profile.following}}</span>
<article>
<p>{{profile.bio}}</p>
</article>
</div>
</paper-card>
</div>
</template>
<script>
Polymer({
is: 'github-card',
properties: {
user: String,
profile: {
type: Object,
value: {}
},
name: {
type: String,
computed: 'computeName(profile)'
}
},
handleResponse: function (response) {
this.profile = response.detail.response;
console.log(this.profile);
},
computeName: function (profile) {
return profile.login + '\'s ' + 'Github profile';
},
ready: function () {
var ajax = this.$.getCard;
ajax.url = 'https://api.github.com/users/' + this.user;
ajax.generateRequest();
}
});
</script>
</dom-module>
<github-card user="tfarla">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment