Skip to content

Commit

Permalink
Hide all-time contributors 2605 (#2967)
Browse files Browse the repository at this point in the history
* Hide contributors div if number of all time contributors is less than number of people on the current project team

* Add explanatory comment
  • Loading branch information
tamara-snyder authored Mar 18, 2022
1 parent 661644b commit c4fbd6d
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions assets/js/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,35 @@ if(project != null){
}
}

// Creates DOM elements for contributors
for(let contributor of contributorsArray){
if (contributorsArray.length >= 1) {
let contributorDiv = document.createElement('div');
contributorDiv.classList.add('contributor-div');

let contributorProfile = document.createElement('a');
contributorProfile.classList.add('contributor-link');
contributorProfile.setAttribute('href', contributor.github_url);
contributorProfile.setAttribute('target', '_blank');
let contributorUrl = contributor.github_url.split('/');
let contributorName = contributorUrl.pop();
contributorProfile.setAttribute('title', contributorName);

let contributorImg = document.createElement('img');
contributorImg.style['border-radius'] = '12px';
contributorImg.setAttribute('src', contributor.avatar_url);

contributorProfile.appendChild(contributorImg);
contributorDiv.appendChild(contributorProfile);
contributors.appendChild(contributorDiv);
let projectTeam = document.querySelectorAll('.leader-card')

if (contributorsArray.length < projectTeam.length) {
// Hides all-time contributors if number of contributors is less than size of current project team
let contributorSection = document.getElementById('contributor-header');
contributorSection.style.display = 'none';
} else {
// Creates DOM elements for contributors
for(let contributor of contributorsArray){
if (contributorsArray.length >= 1) {
let contributorDiv = document.createElement('div');
contributorDiv.classList.add('contributor-div');

let contributorProfile = document.createElement('a');
contributorProfile.classList.add('contributor-link');
contributorProfile.setAttribute('href', contributor.github_url);
contributorProfile.setAttribute('target', '_blank');
let contributorUrl = contributor.github_url.split('/');
let contributorName = contributorUrl.pop();
contributorProfile.setAttribute('title', contributorName);

let contributorImg = document.createElement('img');
contributorImg.style['border-radius'] = '12px';
contributorImg.setAttribute('src', contributor.avatar_url);

contributorProfile.appendChild(contributorImg);
contributorDiv.appendChild(contributorProfile);
contributors.appendChild(contributorDiv);
}
}
}
} else {
Expand Down

0 comments on commit c4fbd6d

Please sign in to comment.