-
+
- Thank you username for being a Node.js contributor.
+ Thank you username for being a Node.js contributor
0 contributions
diff --git a/static/js/main.js b/static/js/main.js
index dd9bb8ec572d3..4d2744878a09e 100644
--- a/static/js/main.js
+++ b/static/js/main.js
@@ -150,11 +150,11 @@
loadingSpinner.remove()
contributorAvatar.classList.remove('hidden')
// Set new values
- contributorAvatar.src = contributor.avatar_url
+ contributorAvatar.src = contributor.avatar_url + '&s=80'
contributorAvatar.parentElement.href = contributor.html_url
- contributorUsername.innerText = contributor.login
+ contributorUsername.textContent = contributor.login
contributorUsername.href = contributor.html_url
- contributorContributions.innerText = contributor.contributions + ' contributions'
+ contributorContributions.textContent = contributor.contributions + ' contributions'
contributorContributions.parentElement.href = 'https://github.com/nodejs/node/commits?author=' + contributor.login
})
}
From 3edc27366091ce13771c205e593fd2bb36381957 Mon Sep 17 00:00:00 2001
From: XhmikosR
Date: Sun, 8 Dec 2019 13:39:57 +0200
Subject: [PATCH 6/7] More tweaks and fix IE >= 10 JS.
Also, move `.hidden` to utils.
---
layouts/css/_utils.scss | 4 +
.../css/page-modules/_contributor-card.scss | 28 +------
layouts/css/page-modules/_header.scss | 4 -
layouts/css/page-modules/_jsfoundation.scss | 4 -
layouts/css/page-modules/spinner.scss | 18 +++++
layouts/css/styles.scss | 1 +
layouts/partials/contributor-card.hbs | 4 +-
static/js/main.js | 79 ++++++++++---------
8 files changed, 71 insertions(+), 71 deletions(-)
create mode 100644 layouts/css/page-modules/spinner.scss
diff --git a/layouts/css/_utils.scss b/layouts/css/_utils.scss
index 47bb272352fe8..92b230207c0d9 100644
--- a/layouts/css/_utils.scss
+++ b/layouts/css/_utils.scss
@@ -25,3 +25,7 @@
white-space: nowrap;
border: none;
}
+
+.hidden {
+ display: none;
+}
diff --git a/layouts/css/page-modules/_contributor-card.scss b/layouts/css/page-modules/_contributor-card.scss
index 190b1372d083e..7d10711d4187c 100644
--- a/layouts/css/page-modules/_contributor-card.scss
+++ b/layouts/css/page-modules/_contributor-card.scss
@@ -1,5 +1,7 @@
.contributor-card {
display: flex;
+ justify-content: space-between;
+ align-items: center;
min-height: 42px;
width: 300px;
padding: 1.5em 1em;
@@ -18,33 +20,11 @@
}
img {
- max-width: initial;
+ max-width: none;
}
- .spinner {
+ .spinner-border {
margin: 5px;
- width: 30px;
- height: 30px;
- border-top-color: $white;
- border-left-color: #444;
- animation: spinner 400ms linear infinite;
- border-bottom-color: transparent;
- border-right-color: transparent;
- border-style: solid;
- border-width: 2px;
- border-radius: 50%;
- box-sizing: border-box;
- display: inline-block;
- }
-
- .hidden {
- display: none;
- }
-}
-
-@keyframes spinner {
- 100% {
- transform: rotate(360deg);
}
}
diff --git a/layouts/css/page-modules/_header.scss b/layouts/css/page-modules/_header.scss
index 955a41604d85e..1f173bc48a22d 100644
--- a/layouts/css/page-modules/_header.scss
+++ b/layouts/css/page-modules/_header.scss
@@ -52,10 +52,6 @@ header {
margin: 0;
padding: 0;
- &.hidden {
- display: none;
- }
-
a {
color: $light-gray2;
}
diff --git a/layouts/css/page-modules/_jsfoundation.scss b/layouts/css/page-modules/_jsfoundation.scss
index 0fc728a2ffaf5..588c3efb4115e 100644
--- a/layouts/css/page-modules/_jsfoundation.scss
+++ b/layouts/css/page-modules/_jsfoundation.scss
@@ -23,10 +23,6 @@
}
.thanking-contributor {
- &.hidden {
- display: none;
- }
-
max-width: 300px;
display: flex;
align-items: center;
diff --git a/layouts/css/page-modules/spinner.scss b/layouts/css/page-modules/spinner.scss
new file mode 100644
index 0000000000000..b3756d56dc702
--- /dev/null
+++ b/layouts/css/page-modules/spinner.scss
@@ -0,0 +1,18 @@
+// borrowed from Bootstrap
+@keyframes spinner-border {
+ to {
+ transform: rotate(360deg);
+ }
+}
+
+.spinner-border {
+ box-sizing: border-box;
+ display: inline-block;
+ width: 2rem;
+ height: 2rem;
+ vertical-align: text-bottom;
+ border: .25em solid currentColor;
+ border-right-color: transparent;
+ border-radius: 50%;
+ animation: spinner-border .75s linear infinite;
+}
diff --git a/layouts/css/styles.scss b/layouts/css/styles.scss
index aff7d30b8c800..971838040c6ee 100644
--- a/layouts/css/styles.scss
+++ b/layouts/css/styles.scss
@@ -22,6 +22,7 @@
@import "page-modules/release-schedule";
@import "page-modules/resources";
@import "page-modules/contributor-card";
+@import "page-modules/spinner";
@import "vendor/prism-tomorrow";
article a {
diff --git a/layouts/partials/contributor-card.hbs b/layouts/partials/contributor-card.hbs
index 6f189eb3e2c1a..ea68ef996eb92 100644
--- a/layouts/partials/contributor-card.hbs
+++ b/layouts/partials/contributor-card.hbs
@@ -1,6 +1,8 @@
-
+
+ Loading...
+
diff --git a/static/js/main.js b/static/js/main.js
index 4d2744878a09e..b66d44b671d02 100644
--- a/static/js/main.js
+++ b/static/js/main.js
@@ -59,7 +59,7 @@
var contributorAvatar = contributorCard.querySelector('#contributor-avatar')
var contributorUsername = contributorCard.querySelector('#contributor-username')
var contributorContributions = contributorCard.querySelector('#contributor-contributions')
- var loadingSpinner = contributorCard.querySelector('.spinner')
+ var loadingSpinner = contributorCard.querySelector('.spinner-border')
if (window.IntersectionObserver) {
var observer = new window.IntersectionObserver(function (entries) {
@@ -112,51 +112,54 @@
function getMaxContributors (callback) {
var xhr = new window.XMLHttpRequest()
- xhr.responseType = 'json'
-
- xhr.open('GET', 'https://api.github.com/repos/nodejs/node/contributors?per_page=1')
- xhr.send()
- xhr.addEventListener('load', function () {
- if (xhr.status !== 200) {
- return contributorCard.remove()
- }
-
- // Get Headers Links last page to generate a random contributor
- var links = linkParser(xhr.getResponseHeader('Link'))
- var randomPage = Math.floor(Math.random() * Math.floor(parseInt(links.last.page, 10))) + 1
-
- if (window.localStorage) {
- window.localStorage.setItem('fetch_date', Date.now())
+ xhr.open('GET', 'https://api.github.com/repos/nodejs/node/contributors?per_page=1', true)
+
+ xhr.onreadystatechange = function () {
+ if (xhr.readyState === 4) {
+ if (xhr.status === 200) {
+ // Get Headers Links last page to generate a random contributor
+ var links = linkParser(xhr.getResponseHeader('Link'))
+ var randomPage = Math.floor(Math.random() * Math.floor(parseInt(links.last.page, 10))) + 1
+
+ if (window.localStorage) {
+ window.localStorage.setItem('fetch_date', Date.now())
+ }
+ callback(randomPage, links.last.page)
+ } else {
+ return contributorCard.parentNode.removeChild(contributorCard)
+ }
}
+ }
- callback(randomPage, links.last.page)
- })
+ xhr.send()
}
function getContributor (randomPage) {
var xhr = new window.XMLHttpRequest()
- xhr.responseType = 'json'
-
- xhr.open('GET', 'https://api.github.com/repos/nodejs/node/contributors?per_page=1&page=' + randomPage)
- xhr.send()
- xhr.addEventListener('load', function () {
- if (xhr.status !== 200) {
- return contributorCard.remove()
+ xhr.open('GET', 'https://api.github.com/repos/nodejs/node/contributors?per_page=1&page=' + randomPage, true)
+
+ xhr.onreadystatechange = function () {
+ if (xhr.readyState === 4) {
+ if (xhr.status === 200) {
+ var contributor = JSON.parse(xhr.responseText)[0]
+
+ // Remove loading spinner and show avatar
+ loadingSpinner.parentNode.removeChild(loadingSpinner)
+ contributorAvatar.classList.remove('hidden')
+ // Set new values
+ contributorAvatar.src = contributor.avatar_url + '&s=80'
+ contributorAvatar.parentElement.href = contributor.html_url
+ contributorUsername.textContent = contributor.login
+ contributorUsername.href = contributor.html_url
+ contributorContributions.textContent = contributor.contributions + ' contributions'
+ contributorContributions.parentElement.href = 'https://github.com/nodejs/node/commits?author=' + contributor.login
+ } else {
+ return contributorCard.parentNode.removeChild(contributorCard)
+ }
}
+ }
- var contributor = xhr.response[0]
-
- // Remove loading spinner and show avatar
- loadingSpinner.remove()
- contributorAvatar.classList.remove('hidden')
- // Set new values
- contributorAvatar.src = contributor.avatar_url + '&s=80'
- contributorAvatar.parentElement.href = contributor.html_url
- contributorUsername.textContent = contributor.login
- contributorUsername.href = contributor.html_url
- contributorContributions.textContent = contributor.contributions + ' contributions'
- contributorContributions.parentElement.href = 'https://github.com/nodejs/node/commits?author=' + contributor.login
- })
+ xhr.send()
}
function linkParser (linkHeader) {
From edbae363ecafbfce83e042ea5d9d651014794939 Mon Sep 17 00:00:00 2001
From: Martijn Cuppens
Date: Thu, 16 Jan 2020 14:03:05 +0100
Subject: [PATCH 7/7] IE fixes
---
layouts/css/page-modules/_contributor-card.scss | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/layouts/css/page-modules/_contributor-card.scss b/layouts/css/page-modules/_contributor-card.scss
index 7d10711d4187c..699608986bed2 100644
--- a/layouts/css/page-modules/_contributor-card.scss
+++ b/layouts/css/page-modules/_contributor-card.scss
@@ -1,6 +1,5 @@
.contributor-card {
display: flex;
- justify-content: space-between;
align-items: center;
min-height: 42px;
width: 300px;
@@ -12,15 +11,13 @@
> a {
height: 40px;
width: 40px;
- margin-right: 1em;
+ flex: 0 0 auto;
}
p {
+ padding-left: 1em;
margin: 0;
- }
-
- img {
- max-width: none;
+ flex: 1 1 1px;
}
.spinner-border {