From 21ff95a7b58445ef4248efcec893419bfd4a4655 Mon Sep 17 00:00:00 2001 From: mxaddict Date: Tue, 25 Jan 2022 01:23:21 +0800 Subject: [PATCH 01/15] Added new contributors list --- content/developers.html | 5 ++ static/css/main.css | 27 +++++++- static/js/developers.js | 137 ++++++++++++++++++++++++++++++++++------ 3 files changed, 148 insertions(+), 21 deletions(-) diff --git a/content/developers.html b/content/developers.html index ca67647e..9df4c077 100644 --- a/content/developers.html +++ b/content/developers.html @@ -145,6 +145,11 @@

Acknowledgement

Title

+
+
+
+ Total contributions: +
diff --git a/static/css/main.css b/static/css/main.css index ab273a3c..83620855 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -2520,7 +2520,7 @@ figcaption { .protocol-contributor-content { display: -ms-grid; display: grid; - padding: 30px; + padding: 30px 20px; grid-auto-flow: row; grid-auto-columns: 1fr; grid-column-gap: 0px; @@ -2564,6 +2564,31 @@ figcaption { background-color: #f0f0f0; } + +.protocol-contributor-button-repo { + margin: 3px; + display:inline-block; + position: relative; + width: auto; + padding: 0px 6px; + -webkit-box-pack: center; + -webkit-justify-content: center; + -ms-flex-pack: center; + justify-content: center; + -webkit-box-align: center; + -webkit-align-items: center; + -ms-flex-align: center; + align-items: center; + border-style: solid; + border-width: 1px; + border-color: #686868; + background-color: #ebebeb; + font-family: 'Gotham Rounded', sans-serif; + color: #050505; + font-size: 12px; + font-weight: normal; + text-align: center; +} .protocol-contributor-title { margin-top: 0px; margin-bottom: 0px; diff --git a/static/js/developers.js b/static/js/developers.js index 58b0ed65..dcbb8405 100644 --- a/static/js/developers.js +++ b/static/js/developers.js @@ -1,20 +1,117 @@ -fetch('https://api.github.com/repos/navcoin/navcoin-core/contributors?anon=true') -.then((result) => result.json()) -.then((data) => { - const grid = document.getElementsByClassName('protocol-contributors-grid')[0]; - const template = document.getElementsByClassName('protocol-contributor-content')[0]; - - for (let i = 0; i < data.length; i++) { - const item = data[i]; - if (item.type == 'User') { - const content = template.cloneNode(true); - content.querySelector('.protocol-contributor-image').src = item.avatar_url; - content.querySelector('.protocol-contributor-title').innerHTML = item.login; - content.querySelector('.protocol-contributor-button').href = item.html_url; - content.style.opacity = '100%'; - grid.append(content); - } - } - - template.remove(); -}); +'use strict' + +let promises = [] +let contributors = {} +let repos = [ + 'navcoin/navcoin-core', + 'navcoin/navcoin-org', + 'navcoin/KnowledgeBase', + + 'agucyalled/nav-react', + 'aguycalled/bitcore-lib', + 'aguycalled/electrum aguycalled/electrumx', + 'aguycalled/electrum-client-js', + 'aguycalled/ledger-app-nav', + 'aguycalled/nav-ledger-loader', + 'aguycalled/navcoin-js', + 'aguycalled/wnav-react', + + 'sakdeniz/next', + 'sakdeniz/next-mobile', +] + +for (let i = 0; i < repos.length; i++) { + const repo = repos[i] + promises.push(fetch(`https://api.github.com/repos/${repo}/contributors`) + .then(result => result.json()) + .then((data) => { + for (let j = 0; j < data.length; j++) { + if (data[j].type == 'User') { + const user = data[j] + const repoObj = { + name: repo, + contributions: user.contributions, + url: `https://github.com/${repo}` + } + + contributors[user.login] = contributors[user.login] || user + contributors[user.login].repos = contributors[user.login].repos || [] + + contributors[user.login].repos.push(repoObj) + + contributors[user.login].contributions_total = contributors[user.login].contributions_total || 0 + contributors[user.login].contributions_total += user.contributions + } + } + })) +} + +Promise.all(promises).then(() => { + console.log(contributors) + + let sortedList = Object.values(contributors).sort((a, b) => { + if (a.contributions_total > b.contributions_total) { + return -1 + } + + if (a.contributions_total < b.contributions_total) { + return 1 + } + + return 0 + }) + + console.log(sortedList) + + const grid = document.getElementsByClassName('protocol-contributors-grid')[0] + const template = document.getElementsByClassName('protocol-contributor-content')[0] + + for (let i = 0; i < sortedList.length; i++) { + const user = sortedList[i] + console.log(user) + const content = template.cloneNode(true) + let repoListHTML = '' + content.querySelector('.protocol-contributor-image').src = user.avatar_url + content.querySelector('.protocol-contributor-title').innerHTML = user.login + content.querySelector('.protocol-contributor-button').href = user.html_url + content.querySelector('.protocol-contributor-contributions').innerHTML = `${user.contributions_total}` + + user.repos.sort((a, b) => { + if (a.contributions > b.contributions) { + return -1 + } + + if (a.contributions < b.contributions) { + return 1 + } + + return 0 + }) + + for (let j = 0; j < user.repos.length; j++) { + const repo = user.repos[j] + let color1 = '46b1e8' + let color2 = 'c42bb7' + let ratio = (repos.indexOf(repo.name) + 1) / repos.length + let hex = (x) => { + x = x.toString(16) + return (x.length == 1) ? '0' + x : x + } + + let r = Math.ceil(parseInt(color1.substring(0,2), 16) * ratio + parseInt(color2.substring(0,2), 16) * (1-ratio)) + let g = Math.ceil(parseInt(color1.substring(2,4), 16) * ratio + parseInt(color2.substring(2,4), 16) * (1-ratio)) + let b = Math.ceil(parseInt(color1.substring(4,6), 16) * ratio + parseInt(color2.substring(4,6), 16) * (1-ratio)) + + let color = hex(r) + hex(g) + hex(b) + + repoListHTML += `${repo.name.replace(/navcoin\//, '')}` + } + + content.querySelector('.protocol-contributor-repos').innerHTML = repoListHTML + + content.style.opacity = '100%' + grid.append(content) + + template.remove(); + } +}) From c113256ce65af244b3edd38b70384b9f55d9c4c4 Mon Sep 17 00:00:00 2001 From: mxaddict Date: Tue, 25 Jan 2022 01:58:26 +0800 Subject: [PATCH 02/15] Added animation to expand repo list --- content/developers.html | 4 ++-- static/css/main.css | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/content/developers.html b/content/developers.html index 9df4c077..863424ff 100644 --- a/content/developers.html +++ b/content/developers.html @@ -147,8 +147,8 @@

Acknowledgement

Title

-
- Total contributions: +
+

contributions

See profile diff --git a/static/css/main.css b/static/css/main.css index 83620855..a19a31de 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -2564,6 +2564,20 @@ figcaption { background-color: #f0f0f0; } +.protocol-contributor-repos { + max-height: 56px; + overflow: hidden; + transition: max-height 0.5s; + -webkit-transition: max-height 0.5s; +} + +.protocol-contributor-repos:hover { + max-height: 1000px; +} + +.protocol-contributor-contributions-label { + font-family: 'Gotham Rounded', sans-serif; +} .protocol-contributor-button-repo { margin: 3px; From 05f4f16f2c3739919461ce33dbac635ce04d0f81 Mon Sep 17 00:00:00 2001 From: mxaddict Date: Tue, 25 Jan 2022 02:29:19 +0800 Subject: [PATCH 03/15] Updated class for the paragraph --- content/developers.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/developers.html b/content/developers.html index 863424ff..d985b791 100644 --- a/content/developers.html +++ b/content/developers.html @@ -147,8 +147,8 @@

Acknowledgement

Title

-
-

contributions

+
+

contributions

See profile From 796ff955c31739093b06b8570302c2ab485d085e Mon Sep 17 00:00:00 2001 From: mxaddict Date: Tue, 25 Jan 2022 02:30:07 +0800 Subject: [PATCH 04/15] Removed animation on hover for repo list --- static/css/main.css | 2 -- 1 file changed, 2 deletions(-) diff --git a/static/css/main.css b/static/css/main.css index a19a31de..b668dddf 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -2567,8 +2567,6 @@ figcaption { .protocol-contributor-repos { max-height: 56px; overflow: hidden; - transition: max-height 0.5s; - -webkit-transition: max-height 0.5s; } .protocol-contributor-repos:hover { From 89526bbcb1048160527f5ba775e792cf28fc49c0 Mon Sep 17 00:00:00 2001 From: mxaddict Date: Tue, 25 Jan 2022 02:31:26 +0800 Subject: [PATCH 05/15] Opps --- static/css/main.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/css/main.css b/static/css/main.css index b668dddf..b05f1ffc 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -2573,7 +2573,7 @@ figcaption { max-height: 1000px; } -.protocol-contributor-contributions-label { +.protocol-contributor-paragraph { font-family: 'Gotham Rounded', sans-serif; } From 6b71437cf187280ce7c8493b8930100bf15c4701 Mon Sep 17 00:00:00 2001 From: mxaddict Date: Tue, 25 Jan 2022 02:33:17 +0800 Subject: [PATCH 06/15] Updated margin on contribution count p tag --- static/css/main.css | 1 + 1 file changed, 1 insertion(+) diff --git a/static/css/main.css b/static/css/main.css index b05f1ffc..91e8764f 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -2575,6 +2575,7 @@ figcaption { .protocol-contributor-paragraph { font-family: 'Gotham Rounded', sans-serif; + margin-bottom: 0; } .protocol-contributor-button-repo { From b31d3b34c3436f3eb9156b27bc1f1154ec27f743 Mon Sep 17 00:00:00 2001 From: mxaddict Date: Tue, 25 Jan 2022 02:36:19 +0800 Subject: [PATCH 07/15] Updated the repo list and sorting --- static/js/developers.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/static/js/developers.js b/static/js/developers.js index dcbb8405..a0483ea2 100644 --- a/static/js/developers.js +++ b/static/js/developers.js @@ -9,7 +9,8 @@ let repos = [ 'agucyalled/nav-react', 'aguycalled/bitcore-lib', - 'aguycalled/electrum aguycalled/electrumx', + 'aguycalled/electrum', + 'aguycalled/electrumx', 'aguycalled/electrum-client-js', 'aguycalled/ledger-app-nav', 'aguycalled/nav-ledger-loader', @@ -76,18 +77,6 @@ Promise.all(promises).then(() => { content.querySelector('.protocol-contributor-button').href = user.html_url content.querySelector('.protocol-contributor-contributions').innerHTML = `${user.contributions_total}` - user.repos.sort((a, b) => { - if (a.contributions > b.contributions) { - return -1 - } - - if (a.contributions < b.contributions) { - return 1 - } - - return 0 - }) - for (let j = 0; j < user.repos.length; j++) { const repo = user.repos[j] let color1 = '46b1e8' From 7c389d8f4aabe5b58c025845e41a0e07f65a8b40 Mon Sep 17 00:00:00 2001 From: mxaddict Date: Tue, 25 Jan 2022 02:45:51 +0800 Subject: [PATCH 08/15] Added back the animation for repo list --- static/css/main.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/static/css/main.css b/static/css/main.css index 91e8764f..e4938fef 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -2567,6 +2567,8 @@ figcaption { .protocol-contributor-repos { max-height: 56px; overflow: hidden; + transition: max-height 0.5s; + -webkit-transition: max-height 0.5s; } .protocol-contributor-repos:hover { From 5af7b1b8ce5ceaf07660a8f15027bf63689ba1c8 Mon Sep 17 00:00:00 2001 From: mxaddict Date: Tue, 25 Jan 2022 02:47:22 +0800 Subject: [PATCH 09/15] Removed console logs --- static/js/developers.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/static/js/developers.js b/static/js/developers.js index a0483ea2..864477fe 100644 --- a/static/js/developers.js +++ b/static/js/developers.js @@ -48,8 +48,6 @@ for (let i = 0; i < repos.length; i++) { } Promise.all(promises).then(() => { - console.log(contributors) - let sortedList = Object.values(contributors).sort((a, b) => { if (a.contributions_total > b.contributions_total) { return -1 @@ -62,14 +60,11 @@ Promise.all(promises).then(() => { return 0 }) - console.log(sortedList) - const grid = document.getElementsByClassName('protocol-contributors-grid')[0] const template = document.getElementsByClassName('protocol-contributor-content')[0] for (let i = 0; i < sortedList.length; i++) { const user = sortedList[i] - console.log(user) const content = template.cloneNode(true) let repoListHTML = '' content.querySelector('.protocol-contributor-image').src = user.avatar_url From 64fb6f6a42608d34350221fe153b3cb0246d7224 Mon Sep 17 00:00:00 2001 From: mxaddict Date: Tue, 25 Jan 2022 02:50:13 +0800 Subject: [PATCH 10/15] Sorted repo list alphabetically --- static/js/developers.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/static/js/developers.js b/static/js/developers.js index 864477fe..469a5c4c 100644 --- a/static/js/developers.js +++ b/static/js/developers.js @@ -72,6 +72,12 @@ Promise.all(promises).then(() => { content.querySelector('.protocol-contributor-button').href = user.html_url content.querySelector('.protocol-contributor-contributions').innerHTML = `${user.contributions_total}` + user.repos.sort((a, b) => { + if(a.name < b.name) { return -1; } + if(a.name > b.name) { return 1; } + return 0; + }) + for (let j = 0; j < user.repos.length; j++) { const repo = user.repos[j] let color1 = '46b1e8' From ff5e9b838ade3963a5c1c6abd7e1fc2c3e5695d5 Mon Sep 17 00:00:00 2001 From: mxaddict Date: Tue, 25 Jan 2022 22:16:22 +0800 Subject: [PATCH 11/15] Added show more/less button --- content/developers.html | 3 +++ static/css/main.css | 29 +++++++++++++++++++++++++++-- static/js/developers.js | 23 +++++++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/content/developers.html b/content/developers.html index d985b791..0696c6c6 100644 --- a/content/developers.html +++ b/content/developers.html @@ -147,6 +147,9 @@

Acknowledgement

Title

+

contributions

diff --git a/static/css/main.css b/static/css/main.css index e4938fef..a71572a7 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -2564,14 +2564,39 @@ figcaption { background-color: #f0f0f0; } +.protocol-contributor-showhide-btn { + margin: 3px; + display:inline-block; + position: relative; + width: 100px; + padding: 0px 6px; + -webkit-box-pack: center; + -webkit-justify-content: center; + -ms-flex-pack: center; + justify-content: center; + -webkit-box-align: center; + -webkit-align-items: center; + -ms-flex-align: center; + align-items: center; + border-style: solid; + border-width: 1px; + border-color: #686868; + background-color: #ebebeb; + font-family: 'Gotham Rounded', sans-serif; + color: #050505; + font-size: 12px; + font-weight: normal; + text-align: center; +} + .protocol-contributor-repos { - max-height: 56px; + max-height: 28px; overflow: hidden; transition: max-height 0.5s; -webkit-transition: max-height 0.5s; } -.protocol-contributor-repos:hover { +.protocol-contributor-repos-expanded { max-height: 1000px; } diff --git a/static/js/developers.js b/static/js/developers.js index 469a5c4c..78ffb2ac 100644 --- a/static/js/developers.js +++ b/static/js/developers.js @@ -102,6 +102,29 @@ Promise.all(promises).then(() => { content.style.opacity = '100%' grid.append(content) + let el = content.querySelector('.protocol-contributor-repos') + + if (el.scrollHeight > el.clientHeight) { + let showHide = content.querySelector('.protocol-contributor-showhide') + let showHideBtn = content.querySelector('.protocol-contributor-showhide-btn') + showHide.style.display = 'block' + + let expanded = false + showHideBtn.onclick = () => { + // Switch it up + expanded = expanded ? false : true + + // Add our class + if (expanded) { + content.querySelector('.protocol-contributor-repos').classList.add('protocol-contributor-repos-expanded') + content.querySelector('.protocol-contributor-showhide-btn').innerHTML = 'Show less' + } else { + content.querySelector('.protocol-contributor-repos').classList.remove('protocol-contributor-repos-expanded') + content.querySelector('.protocol-contributor-showhide-btn').innerHTML = 'Show more' + } + } + } + template.remove(); } }) From bd2120a586859d593940d08f4d286fbbf3dcc5ab Mon Sep 17 00:00:00 2001 From: mxaddict Date: Wed, 26 Jan 2022 00:52:12 +0800 Subject: [PATCH 12/15] Removed underline from show more/less button and changed the with to match the repo boxes --- content/developers.html | 2 +- static/css/main.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/developers.html b/content/developers.html index 0696c6c6..abf53b58 100644 --- a/content/developers.html +++ b/content/developers.html @@ -148,7 +148,7 @@

Acknowledgement

contributions

diff --git a/static/css/main.css b/static/css/main.css index a71572a7..ab502f39 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -2568,7 +2568,7 @@ figcaption { margin: 3px; display:inline-block; position: relative; - width: 100px; + width: auto; padding: 0px 6px; -webkit-box-pack: center; -webkit-justify-content: center; From 0d3bd29bf1a7e7f60189e3e5974acb5f525d45bc Mon Sep 17 00:00:00 2001 From: mxaddict Date: Wed, 26 Jan 2022 01:33:39 +0800 Subject: [PATCH 13/15] Added some missing styles for a paragraph and added a flex element to the contributor titles --- content/developers.html | 4 +++- static/css/main.css | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/content/developers.html b/content/developers.html index abf53b58..957c1ee2 100644 --- a/content/developers.html +++ b/content/developers.html @@ -144,7 +144,9 @@

Acknowledgement

-

Title

+
+

Title

+