Skip to content

Commit

Permalink
make filter for recent contributors list. (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishabh570 authored Aug 3, 2019
1 parent 2ae45b5 commit fd36b6a
Show file tree
Hide file tree
Showing 18 changed files with 737 additions and 270 deletions.
354 changes: 253 additions & 101 deletions dist/community-toolbox.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/copyToClipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ document.addEventListener("DOMContentLoaded", function() {
copyButton.map(function(item, ele) {
ele.addEventListener("click", function(event) {
event.preventDefault();
usernames = $(this).parent().children(this.lastChild).find(".usernames")[0];
usernames = $(this).parent().parent().find(".usernames")[0];
let names = usernames.textContent;
dummyInp.setAttribute('type', 'text');
dummyInp.setAttribute('value', `${names}`);
Expand Down
113 changes: 96 additions & 17 deletions examples/demo.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,40 @@ h1, h2, .section h3 {
margin-top: 2em;
}

.dropdown {
.stale-container {
padding: 10px;
background-color: rgba(221, 221, 221, 0.493);
border-radius: 10px;

}

.stale {
overflow: scroll;
height: 1000px;
}


.fto-authors {
padding: 19px;
margin-bottom: 20px;
background-color: #f5f5f5;
border: 1px solid #e3e3e3;
border-radius: 4px;
box-shadow: inset 0 1px 1px rgba(0,0,0,.05);
}


.recent-contrib-content-box {
padding: 19px;
}

.recent-contributors-body {
padding: 0;
}

/* DROPDOWNS */

.dropdown-Repo {
margin-left: auto;
}

Expand All @@ -111,36 +144,80 @@ h1, h2, .section h3 {
padding: 3px;
}

.dropdown-items:hover{
.dropdown-items:hover,
.past p:hover,
.sort-items:hover {
cursor: pointer;
background-color: rgba(221, 221, 255, 0.226);
}
.stale-container {
padding: 10px;
background-color: rgba(221, 221, 221, 0.493);
border-radius: 10px;

.past {
margin-bottom: 5px;
height: 1.7em;
width: auto;
text-align: center;
}

.stale {
overflow: scroll;
height: 1000px;
.past p {
margin: 0;
}

.recent-contribs-show-dropdown,
.recent-contribs-dropdown {
display: inline-block;
height: 100%;
}
.recent-contribs-dropdown {
width: 10%;
text-align: center;
}
.recent-contribs-show-dropdown {
width: 12em;
}

.fto-authors {
padding: 19px;
margin-bottom: 20px;
background-color: #f5f5f5;
border: 1px solid #e3e3e3;
border-radius: 4px;
box-shadow: inset 0 1px 1px rgba(0,0,0,.05);
.dropdown-toggle-RC {
display: inline-block;
text-align: center;
margin-top: 9px;
}

.dropdown-menu {
top: 80%;
background-color: #f6f8fa;
}

#dropdownMenuButtonRCS {
font-weight: bolder;
}
#dropdownMenuButtonRC,
#dropdownMenuButtonRCS {
font-family: 'Open sans', serif;
}

#dropdownMenuButtonRC:hover,
#dropdownMenuButtonRCS:hover {
cursor: pointer;
color: #111111;
font-weight: bold;
}

.filter-options {
border: 1px solid #d1d5da;
background-color: #f6f8fa;
color: #566069;
height: 40px;
display: flex;
justify-content: flex-end;
}



/* COPY TO CLIPBOARD BUTTON */

.copybutton {
width: 30px;
height: 25px;
float: right;
/* float: right; */
border-radius: 3px;
border: none;
box-shadow: 1px 1px 1px 1px #e2abab;
Expand All @@ -163,6 +240,8 @@ h1, h2, .section h3 {
}


/* MEDIA QUERIES */

@media only screen and (max-width: 569px) {
.links {
width: 25%;
Expand Down
58 changes: 36 additions & 22 deletions examples/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,7 @@ document.addEventListener('DOMContentLoaded', function () {
var recencyLabel = urlHash().getUrlHashParameter('l') || 'week';

toolbox = CommunityToolbox(org, repo);

let d = document.getElementById('toggle-contributors');
let recency_label = document.getElementById('recency-label');
d.addEventListener("click", (e) => {
e.preventDefault();
if (recencyLabel=="week") {
toolbox.showRecentContributors(org, repo, recencyLabel);
d.innerHTML = "Show monthly";
recency_label.innerHTML = "last week: ";
recencyLabel = "month";
}else if (recencyLabel=="month") {
toolbox.showRecentContributors(org, repo, recencyLabel);
d.innerHTML = "Show weekly";
recency_label.innerHTML = "last month: ";
recencyLabel = "week";
}
})


if (repo === 'all') {

toolbox.getIssuesForOrg(org, { qs: { labels: ftoLabel } })
Expand All @@ -67,10 +50,10 @@ document.addEventListener('DOMContentLoaded', function () {

toolbox.initialize(org, repo).then((res)=> {
if(res) {
// Fetches and shows recent contributors' list
toolbox.showRecentContributors(org, repo, recencyLabel);
// compile and display all contributors for given org
toolbox.showAllContributors(org, repo);
// Makes the toggle contributors list button click
d.click();
toolbox.dropdownInit();
// Fetch stale issues
toolbox.showStaleIssues(org, repo);
Expand All @@ -89,10 +72,10 @@ document.addEventListener('DOMContentLoaded', function () {

toolbox.initialize(org, repo).then((res)=> {
if(res) {
// Fetches and shows recent contributors' list
toolbox.showRecentContributors(org, repo, recencyLabel);
// compile and display all contributors for given repo
toolbox.showRepoContributors(org, repo);
// Makes the toggle contributors list button click
d.click();
toolbox.dropdownInit();
// Fetch stale issues
toolbox.showStaleIssues(org, repo);
Expand Down Expand Up @@ -122,6 +105,37 @@ document.addEventListener('DOMContentLoaded', function () {
toolbox.ftoAuthorsUI.insertFtoIssueAuthor(ftoAuthArray);
}
}


// EVENT LISTENERS FOR FILTER IN RECENT CONTRIBUTORS SECTION
$('#alphabetic').click((e)=> {
e.preventDefault();
toolbox.filter(org, 'alphabetic');
})

$('#mostrecentfirst').click((e)=> {
e.preventDefault();
toolbox.filter(org, 'mostrecentfirst');
})

$(".past").click((e) => {
e.preventDefault();
let timeSpan = e.target.textContent;
$('#dropdownMenuButtonRCS > #content').html(timeSpan);
let forMonths = 6;
if(timeSpan.includes('Week')) {
timeSpan = 'week';
}else {
let mid = timeSpan.split('Last ')[1].split(' ')[0];
timeSpan = 'month';
forMonths = mid;
}
toolbox.showRecentContributors(org, repo, timeSpan, forMonths);

})




})();

Expand Down
64 changes: 36 additions & 28 deletions examples/themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
var body=document.querySelector('body');
var toggleButton=document.getElementById('myonoffswitch');
var toggle = localStorage.getItem('currentToggle');
var night_adapt = document.getElementsByClassName('nightmode-adapt')[0];

// Sets images' theme accordingly when the page is loaded
setTimeout(()=> {
Expand All @@ -22,7 +21,8 @@
images.forEach((image)=>{
image.style.filter = 'invert(1) grayscale(1)';
image.style.transitionProperty = 'filter';
image.style.transitionDuration = '0.5s';
image.style.transitionDuration = '0.5s';
image.style.transitionTimingFunction = 'linear';
})

// styles for toggle button
Expand All @@ -38,15 +38,16 @@
images.forEach((image)=>{
image.style.filter = 'invert(0) grayscale(0)';
image.style.transitionProperty = 'filter';
image.style.transitionDuration = '0.5s';
image.style.transitionDuration = '0.5s';
image.style.transitionTimingFunction = 'linear';
})

// styles for toggle button
inner.style.removeProperty('margin-left');
switcher.style.removeProperty('right');
switcher.style.removeProperty('background-color');
}
}, 1000)
}, 2000)


// Toggles the theme of the page
Expand All @@ -68,7 +69,8 @@
images.forEach((image)=>{
image.style.filter = 'invert(0) grayscale(0)';
body.style.transitionProperty = 'filter';
image.style.transitionDuration = '0.5s';
image.style.transitionDuration = '0.5s';
image.style.transitionTimingFunction = 'linear';
})

// styles for toggle button
Expand All @@ -86,7 +88,8 @@
images.forEach((image)=>{
image.style.filter = 'invert(1) grayscale(1)';
image.style.transitionProperty = 'filter';
image.style.transitionDuration = '0.5s';
image.style.transitionDuration = '0.5s';
image.style.transitionTimingFunction = 'linear';
})

// styles for toggle button
Expand All @@ -95,32 +98,37 @@
switcher.style.backgroundColor = '#34A7C1';

}
}, 100);
}, 300);
});


// Converts images' theme inside recent contributors section according to the mode selected
// every time the toggle button is clicked
night_adapt.addEventListener("click", function (e) {
e.preventDefault();
setTimeout(() => {
var recentContribsSectionImgs = document.getElementsByClassName('recent-contributors')[0].getElementsByTagName("img");
let check=localStorage.getItem('currentToggle');
let images = [...recentContribsSectionImgs ];
if(check==="night") {
buttonClickCallbackNightTheme = (e) => {
e.preventDefault();
setTimeout(() => {
var recentContribsSectionImgs = document.getElementsByClassName('recent-contributors')[0].getElementsByTagName("img");
let check=localStorage.getItem('currentToggle');
let images = [...recentContribsSectionImgs ];
if(check==="night") {
images.forEach((image) => {
image.style.filter = 'grayscale(1) invert(1)';
image.style.transitionProperty = 'filter';
image.style.transitionDuration = '0.5s';
image.style.transitionTimingFunction = 'linear';
})
}else {
images.forEach((image) => {
image.style.filter = 'invert(1) grayscale(1)';
image.style.transitionProperty = 'filter';
image.style.transitionDuration = '0.5s';
image.style.filter = 'grayscale(0) invert(0)';
image.style.transitionProperty = 'filter';
image.style.transitionDuration = '0.5s';
image.style.transitionTimingFunction = 'linear';
})
}else {
images.forEach((image) => {
image.style.filter = 'invert(0) grayscale(0)';
image.style.transitionProperty = 'filter';
image.style.transitionDuration = '0.5s';
})
}
}, 100);
})
}
}, 300);
}

// Converts images' theme inside recent contributors section according to the mode selected
// every time the toggle button is clicked
$('.past').click((e) => buttonClickCallbackNightTheme(e));
$('.sort-options').click((e) => buttonClickCallbackNightTheme(e));

})
Loading

0 comments on commit fd36b6a

Please sign in to comment.