-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #665 from ayush-848/master
Added Our Contributors page
- Loading branch information
Showing
7 changed files
with
221 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* Contribute.css */ | ||
|
||
.contributor-heading { | ||
font-size: 3rem !important; | ||
} | ||
|
||
.contributor-cards { | ||
display: flex; | ||
flex-wrap: wrap; | ||
justify-content: flex-start; | ||
gap: 20px; | ||
margin-left: 10%; | ||
} | ||
|
||
|
||
.contributor-member { | ||
width: 180px; | ||
padding: 10px; | ||
border: 1px solid #ccc; | ||
border-radius: 5px; | ||
text-align: center; | ||
background-color: #cce5ff; /* Light bluish background color */ | ||
} | ||
|
||
.contributor-member:hover{ | ||
transform: translateY(-5px); | ||
box-shadow: black 14px; | ||
cursor: pointer; | ||
} | ||
|
||
.contributor-member img { | ||
width: 100px; | ||
height: 100px; | ||
border-radius: 50%; | ||
margin-bottom: 10px; | ||
} | ||
|
||
.contributor-member h3 { | ||
font-size: 16px; | ||
} | ||
|
||
.contributor-member p { | ||
font-size: 14px; | ||
} | ||
|
||
.pagination { | ||
display: flex; | ||
justify-content: center; | ||
margin-top: 20px; | ||
} | ||
|
||
.pagination-button { | ||
margin: 0 5px; | ||
padding: 8px 12px; | ||
border: 1px solid #ccc; | ||
border-radius: 5px; | ||
background-color: #fff; | ||
cursor: pointer; | ||
} | ||
|
||
.pagination-button.active { | ||
background-color: #007bff; | ||
color: #fff; | ||
border-color: #007bff; | ||
} | ||
|
||
.pagination-button:hover { | ||
background-color: #e9ecef; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import './Contribute.css'; // Import CSS file for styles | ||
|
||
const Contribute = () => { | ||
const owner = 'Counselllor'; | ||
const repo = 'Counsellor-Web'; | ||
const contributorsPerPage = 5; // Changed to display 5 contributors per page | ||
const [contributors, setContributors] = useState([]); | ||
const [currentPage, setCurrentPage] = useState(1); | ||
|
||
useEffect(() => { | ||
const fetchContributors = async () => { | ||
try { | ||
const response = await fetch(`https://api.github.com/repos/${owner}/${repo}/contributors`); | ||
if (!response.ok) { | ||
console.error('Failed to fetch contributors:', response.statusText); | ||
return; | ||
} | ||
const data = await response.json(); | ||
setContributors(data); | ||
} catch (error) { | ||
console.error('Error fetching contributors:', error); | ||
} | ||
}; | ||
|
||
fetchContributors(); | ||
}, [owner, repo]); | ||
|
||
const handleProfileClick = (username) => { | ||
const profileUrl = `https://github.com/${username}`; | ||
window.open(profileUrl, '_blank'); // Open the GitHub profile in a new tab | ||
}; | ||
|
||
const displayContributors = () => { | ||
const startIndex = (currentPage - 1) * contributorsPerPage; | ||
const endIndex = startIndex + contributorsPerPage; | ||
return contributors.slice(startIndex, endIndex).map(contributor => ( | ||
<div key={contributor.login} className="contributor-member" onClick={() => handleProfileClick(contributor.login)}> | ||
<img src={contributor.avatar_url} alt={contributor.login} /> | ||
<div> | ||
<h3>{contributor.login}</h3> | ||
<p>{contributor.contributions} contributions</p> | ||
</div> | ||
</div> | ||
)); | ||
}; | ||
|
||
const createPaginationButtons = () => { | ||
const totalPages = Math.ceil(contributors.length / contributorsPerPage); | ||
return Array.from({ length: totalPages }, (_, index) => ( | ||
<button | ||
key={index + 1} | ||
className={`pagination-button ${currentPage === index + 1 ? 'active' : ''}`} | ||
onClick={() => setCurrentPage(index + 1)} | ||
> | ||
{index + 1} | ||
</button> | ||
)); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<h1 className='contributor-heading'>Our Contributors</h1> | ||
<div className="contributor-cards"> | ||
{displayContributors()} | ||
</div> | ||
<div className="pagination"> | ||
{createPaginationButtons()} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Contribute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters