Last active
September 12, 2015 12:47
-
-
Save tomodutch/d2cb2d9f47815d0df87e 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
<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> |
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
<github-card user="tfarla"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment