Created
November 26, 2017 16:43
-
-
Save AlgusDark/9368de6ea8a526c1ed92eab6ac30969d to your computer and use it in GitHub Desktop.
S00E12 - HTML+CSS+JS | Codeando Pues — https://youtu.be/ZrxPs75oIR0
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> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" href="reset.css"> | |
<link rel="stylesheet" href="style.css"> | |
<title>My Repositories</title> | |
</head> | |
<body> | |
<div class='card'> | |
<div class='card-body'> | |
<div class='card-avatar'> | |
<img id='avatar'> | |
</div> | |
<div class="card-info"> | |
<h1 id='card-name'></h1> | |
<h3>Codeando Pues</h3> | |
<p class="card-bio"></p> | |
</div> | |
</div> | |
</div> | |
<h2>Repositories</h2> | |
<ul id="repos"></ul> | |
<script src='magic.js'></script> | |
</body> | |
</html> |
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
const endpoint = 'https://api.github.com/users'; | |
const user = 'gaearon'; | |
const userInfo = | |
fetch(`${endpoint}/${user}`) | |
.then(response => response.json()); | |
const repos = | |
fetch(`${endpoint}/${user}/repos`) | |
.then(response => response.json()); | |
Promise.all([userInfo, repos]) | |
.then(([userInfo, repos]) => { | |
printCardInfo(userInfo); | |
printRepos(repos); | |
}); | |
function printCardInfo(userInfo) { | |
document.querySelector('#card-name').innerHTML = userInfo.login; | |
document.querySelector('.card-bio').innerHTML = userInfo.bio; | |
document.querySelector('#avatar').src = userInfo.avatar_url; | |
} | |
function printRepos(repos){ | |
const ul = document.querySelector('#repos'); | |
const fragment = document.createDocumentFragment(); | |
for(let i=0; i < repos.length; i++){ | |
const li = document.createElement('li'); | |
const name = document.createElement('h1'); | |
const description = document.createElement('h2'); | |
name.innerHTML = `<strong>Name:</strong> <a href="${repos[i].html_url}">${repos[i].name}</a>`; | |
description.innerHTML = '<strong>Description:</strong>' + getDescription(repos[i]); | |
li.appendChild(name); | |
li.appendChild(description); | |
fragment.appendChild(li); | |
} | |
ul.appendChild(fragment); | |
} | |
function getDescription(repo){ | |
return repo.description ? repo.description : '...'; | |
} |
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
/* http://meyerweb.com/eric/tools/css/reset/ | |
v2.0 | 20110126 | |
License: none (public domain) | |
*/ | |
html, body, div, span, applet, object, iframe, | |
h1, h2, h3, h4, h5, h6, p, blockquote, pre, | |
a, abbr, acronym, address, big, cite, code, | |
del, dfn, em, img, ins, kbd, q, s, samp, | |
small, strike, strong, sub, sup, tt, var, | |
b, u, i, center, | |
dl, dt, dd, ol, ul, li, | |
fieldset, form, label, legend, | |
table, caption, tbody, tfoot, thead, tr, th, td, | |
article, aside, canvas, details, embed, | |
figure, figcaption, footer, header, hgroup, | |
menu, nav, output, ruby, section, summary, | |
time, mark, audio, video { | |
margin: 0; | |
padding: 0; | |
border: 0; | |
font-size: 100%; | |
font: inherit; | |
vertical-align: baseline; | |
} | |
/* HTML5 display-role reset for older browsers */ | |
article, aside, details, figcaption, figure, | |
footer, header, hgroup, menu, nav, section { | |
display: block; | |
} | |
body { | |
line-height: 1; | |
} | |
ol, ul { | |
list-style: none; | |
} | |
blockquote, q { | |
quotes: none; | |
} | |
blockquote:before, blockquote:after, | |
q:before, q:after { | |
content: ''; | |
content: none; | |
} | |
table { | |
border-collapse: collapse; | |
border-spacing: 0; | |
} |
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
*, *:before, *:after { | |
box-sizing: border-box; | |
} | |
body{ | |
font-size: 16px; | |
} | |
.card { | |
min-height: 100px; | |
padding: 20px; | |
border-radius: 3px; | |
background-color: white; | |
box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.2); | |
position: relative; | |
overflow: hidden; | |
margin: 0 auto; | |
width: 500px; | |
} | |
.card-body{ | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
} | |
.card-avatar{ | |
border: 2px solid #000; | |
border-radius: 50%; | |
height: 120px; | |
width: 120px; | |
position: relative; | |
} | |
.card-avatar img{ | |
border-radius: 50%; | |
height: 100%; | |
width: 100%; | |
position: absolute; | |
} | |
.card-info{ | |
padding-left:20px; | |
} | |
.card-info h1{ | |
font-size: 1.8em; | |
} | |
.card-info h3{ | |
font-size: 1.2em; | |
font-style: italic; | |
} | |
.card-bio{ | |
padding: 10px 0px; | |
} | |
#repos li{ | |
background: #FFF; | |
padding: 20px; | |
border: 1px solid #CCC; | |
color: #666; | |
border-top: 9px solid #39D1B4; | |
margin-bottom: 10px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment