Skip to content

Commit 69fe4d3

Browse files
Added Contributors 😎
1 parent 0ca62a7 commit 69fe4d3

File tree

3 files changed

+120
-0
lines changed

3 files changed

+120
-0
lines changed

css/contributors.css

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
@import 'https://fonts.googleapis.com/css?family=Permanent+Marker';
2+
3+
.contributors {
4+
margin: 2rem 0;
5+
padding: 0;
6+
display: flex;
7+
flex-direction: column;
8+
justify-content: center;
9+
align-items: center;
10+
}
11+
12+
.contributors h1 {
13+
font: 5.5vw/1 Permanent Marker;
14+
color: black;
15+
font-size: 2.5rem;
16+
margin-bottom: 2%;
17+
display: inline-block;
18+
opacity: 0.7;
19+
}
20+
21+
.contributors h1:hover {
22+
opacity: 1;
23+
text-decoration: underline;
24+
}
25+
26+
#contributor {
27+
width: 85%;
28+
display: flex;
29+
flex-wrap: wrap;
30+
justify-content: center;
31+
align-items: center;
32+
}
33+
34+
.contributor-card {
35+
width: 65px;
36+
height: 65px;
37+
margin: 5px;
38+
clip-path: polygon(50% 0%, 91% 25%, 91% 75%, 50% 100%, 9% 75%, 9% 25%);
39+
}
40+
41+
.contributor-card img {
42+
width: 100%;
43+
height: 100%;
44+
object-fit: cover;
45+
transition: opacity 0.3s ease-in-out;
46+
}
47+
48+
.contributor-card img:hover {
49+
width: 78px;
50+
height: 78px;
51+
opacity: 1;
52+
}
53+
54+
.contributor-card img:not(:hover) {
55+
opacity: 0.8;
56+
}
57+
58+
.contributor-card:nth-child(4n+1),
59+
.contributor-card:nth-child(4n+3) {
60+
margin-top: -1.6rem;
61+
}

index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.17/dist/tailwind.min.css" rel="stylesheet">
77
<link href="css/style.css" rel="stylesheet">
8+
<link rel="stylesheet" href="./css/contributors.css">
89
<title>GitHub Automation Scripts 🤖</title>
910
<style>
1011

@@ -191,6 +192,10 @@ <h1 class="text-xl font-semibold mb-4">License</h1>
191192
</pre>
192193
</div>
193194
</main>
195+
<div class="contributors">
196+
<h1>Our Valuable Contributors</h1>
197+
<div id="contributor"></div>
198+
</div>
194199
<footer class="bg-gray-200 py-4">
195200
<div class="container mx-auto px-4">
196201
<p class="text-sm text-gray-600">© 2023 GitHub Automation Scripts 🤖. All rights reserved.</p>
@@ -199,6 +204,7 @@ <h1 class="text-xl font-semibold mb-4">License</h1>
199204
</div>
200205

201206
<script src="js/scripts.js"></script>
207+
<script src="./js/contributors.js"></script>
202208
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/js/all.min.js"></script>
203209
</body>
204210
</html>

js/contributors.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const cont = document.getElementById('contributor');
2+
3+
async function fetchContributors(pageNumber) {
4+
const perPage = 100;
5+
const url = `https://api.github.com/repos/sahil-sagwekar2652/GitHub-Automation-scripts/contributors?page=${pageNumber}&per_page=${perPage}`;
6+
7+
const response = await fetch(url);
8+
if (!response.ok) {
9+
throw new Error(`Failed to fetch contributors data. Status code: ${response.status}`);
10+
}
11+
12+
const contributorsData = await response.json();
13+
return contributorsData;
14+
}
15+
16+
// Function to fetch all contributors
17+
async function fetchAllContributors() {
18+
let allContributors = [];
19+
let pageNumber = 1;
20+
21+
try {
22+
while (true) {
23+
const contributorsData = await fetchContributors(pageNumber);
24+
if (contributorsData.length === 0) {
25+
break;
26+
}
27+
allContributors = allContributors.concat(contributorsData);
28+
pageNumber++;
29+
}
30+
31+
// Display contributors in the honeycomb-like layout
32+
allContributors.forEach((contributor) => {
33+
const contributorCard = document.createElement('div');
34+
contributorCard.classList.add('contributor-card');
35+
36+
const avatarImg = document.createElement('img');
37+
avatarImg.src = contributor.avatar_url;
38+
avatarImg.alt = `${contributor.login}'s Picture`;
39+
40+
const loginLink = document.createElement('a');
41+
loginLink.href = contributor.html_url;
42+
loginLink.appendChild(avatarImg);
43+
44+
contributorCard.appendChild(loginLink);
45+
46+
cont.appendChild(contributorCard);
47+
});
48+
} catch (error) {
49+
console.error(error);
50+
}
51+
}
52+
53+
fetchAllContributors();

0 commit comments

Comments
 (0)