Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Contributor's Page #296

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import './App.css';
import PreNavbar from './components/PreNavbar';
import {BrowserRouter as Router } from "react-router-dom";
import AllRoutes from './components/AllRoutes.jsx';
import ScrollToTop from './components/Scrolltotop.jsx';
// App.js
import React from "react";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import PreNavbar from "./components/PreNavbar";
import ScrollToTop from "./components/Scrolltotop";
import Contributors from "./components/Contributors"; // Import the Contributors component
import Home from "./components/Home"; // Import your Home component or main page component

function App() {
return (

<Router>
<PreNavbar/>
<PreNavbar />
<ScrollToTop />
<AllRoutes/>
{/* Define Routes here */}
<Routes>
<Route path="/" element={<Home />} />{" "}
{/* Main page or home component */}
<Route path="/Contributors" element={<Contributors />} />{" "}
{/* Contributors page */}
</Routes>
</Router>
);
}

export default App;
export default App;
143 changes: 143 additions & 0 deletions frontend/src/components/Contributors.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
.contributors-container {
width: 100%;
height: 100%;
padding-top: 2rem;
overflow: hidden;
}

.github-icon {
margin-right: 0.5rem;
vertical-align: middle;
fill: white; /* Adjust color as needed */
}

.contributors-title {
margin-top: 0rem;
text-align: center;
color: #170374;
font-size: 2.5rem;
font-weight: bold;
margin-bottom: 2rem;
text-transform: uppercase;
box-shadow: #015a92;
}

.contributors-grid {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 2.5rem;
margin-bottom: 4rem;
}

.contributor-card {
position: relative;
width: 100%;
max-width: 20%;
display: flex;
flex-direction: column;
align-items: center;
background-color: rgb(189, 187, 188);
border: 2px solid #0993fd;
border-radius: 0.5rem;
box-shadow: rgba(0, 0, 0, 0.4);
padding: 1rem;
overflow: hidden;
transition: transform 0.4s ease, box-shadow 0.3s ease;
}

.contributor-card:hover {
transform: scale(1.05);
box-shadow: 0 4px 6px rgba(1, 3, 3, 0.7);
}

.contributor-card:hover p {
color: black;
text-shadow: 1px 1px 2px rgb(11, 1, 60), 0 0 0.2em rgb(0, 191, 255),
0 0 0.8em rgb(135, 206, 235);
color: rgb(0, 0, 0);
font-weight: 500;
}

.contributor-card:hover h2 {
text-shadow: 1px 1px 2px rgba(33, 1, 160, 0.926), 0 0 0.2em rgb(162, 35, 6),
0 0 0.8em rgb(4, 20, 163);
color: white;
font-size: 1.04rem;
font-weight: 600;
text-decoration: wavy;
}

.contributor-card:hover .contributor-avatar {
border: 3.5px solid #080101;
width: 5.2rem;
box-shadow: -2px 4px 10px 1px rgba(6, 1, 1, 0.75);
height: 5.2rem;
}

.contributor-card::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: white;
transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
transform: translate(-100%, -100%);
opacity: 0;
z-index: -1;
}

.contributor-card:hover::before {
box-shadow: rgba(6, 1, 1, 0.9);
}

.contributor-link {
display: block;
color: black;
}

.contributor-avatar {
width: 5rem;
height: 5rem;
border-radius: 50%;
object-fit: cover;
margin-bottom: 1rem;
border: 2px solid #070704;
transition: border 0.4s ease-in-out, height 0.4s ease-in-out,
width 0.4s ease-in-out, box-shadow 0.3s ease-in-out;
}

.contributor-name {
font-size: 1rem;
font-weight: 600;
color: #060606;
margin-bottom: 0.5rem;
transition: text-shadow 0.4s ease-in-out, font-size 0.5s ease-in-out,
text-decoration 0.4s ease-in-out;
}

.contributor-contributions {
color: rgb(1, 6, 131);
transition: text-shadow 0.4s ease-in-out;
}

/* Media Queries for Responsiveness */
@media (max-width: 1200px) {
.contributor-card {
max-width: 33.333%;
}
}

@media (max-width: 992px) {
.contributor-card {
max-width: 50%;
}
}

@media (max-width: 768px) {
.contributor-card {
max-width: 97%;
}
}
104 changes: 104 additions & 0 deletions frontend/src/components/Contributors.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import React, { useEffect, useState } from "react";
import axios from "axios";
import "./Contributors.css";

function Contributors() {
const [contributors, setContributors] = useState([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);

useEffect(() => {
async function fetchContributors() {
let allContributors = [];
let page = 1;

try {
while (true) {
const response = await axios.get(
`https://api.github.com/repos/soham0005/ElectroKart/contributors`,
{
params: {
per_page: 100,
page,
},
}
);
const data = response.data;

// Check GitHub rate limit
const remaining = response.headers["x-ratelimit-remaining"];
if (remaining === "0") {
setError("Rate limit exceeded. Please try again later.");
break;
}

if (data.length === 0) {
break;
}

allContributors = [...allContributors, ...data];
page++;
}

// Sort contributors by number of contributions
allContributors.sort((a, b) => b.contributions - a.contributions);
setContributors(allContributors);
} catch (error) {
console.error("Error fetching contributors:", error.message);
setError("Failed to load contributors. Please try again later.");
} finally {
setLoading(false);
}
}
fetchContributors();
}, []);

if (loading) {
return <div className="loading-message">Loading contributors...</div>;
}

if (error) {
return (
<div className="error-message">
<p>{error}</p>
</div>
);
}

return (
<div className="contributors-container">
<h1 className="contributors-title">Our Contributors</h1>
<div className="contributors-grid">
{contributors.length > 0 ? (
contributors.map((contributor) => (
<div key={contributor.id} className="contributor-card">
<a
href={contributor.html_url}
className="contributor-link"
target="_blank"
rel="noopener noreferrer"
>
<img
src={contributor.avatar_url}
alt={contributor.login}
onError={(e) => {
e.target.src = "path/to/fallback_image.png";
}}
className="contributor-avatar"
/>
</a>
<h2 className="contributor-name">{contributor.login}</h2>
<p className="contributor-contributions">
Contributions: {contributor.contributions}
</p>
</div>
))
) : (
<p>No contributors found.</p>
)}
</div>
</div>
);
}

export default Contributors;
14 changes: 14 additions & 0 deletions frontend/src/components/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "react-toastify/dist/ReactToastify.css";
import { FaInstagram, FaLinkedin, FaGithub } from "react-icons/fa";
import { FaXTwitter } from "react-icons/fa6";
import GoogleTranslate from "./GoogleTranslate";
import { Link } from "react-router-dom";

function Footer({ footer }) {
const [loading, setLoading] = useState(false);
Expand Down Expand Up @@ -99,6 +100,18 @@ function Footer({ footer }) {
</a>
))}
</div>
<Link to="/Contributors">
<button
style={{
backgroundColor: "rgb(26, 26, 46)",
color: "white",
border: "none",
cursor: "pointer",
}}
>
Contributors
</button>
</Link>
</div>

<div className="footer-section">
Expand All @@ -111,6 +124,7 @@ function Footer({ footer }) {
>
Contact Us
</h3>

<div
style={{
display: "flex",
Expand Down
12 changes: 12 additions & 0 deletions node_modules/.bin/loose-envify

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/loose-envify.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/.bin/loose-envify.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading