Skip to content

Commit

Permalink
Merge pull request #297 from TBorundia/master
Browse files Browse the repository at this point in the history
Added Contributor's Page
  • Loading branch information
PRathod27 authored Nov 5, 2024
2 parents 912447b + ab16eba commit 3e78e36
Show file tree
Hide file tree
Showing 5 changed files with 275 additions and 15 deletions.
17 changes: 8 additions & 9 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
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';
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";
function App() {
return (

<Router>
<PreNavbar/>
<PreNavbar />
<ScrollToTop />
<AllRoutes/>
<AllRoutes />
</Router>
);
}

export default App;
export default App;
12 changes: 6 additions & 6 deletions frontend/src/components/AllRoutes.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from "react";
import { Routes, Route } from "react-router-dom"
import { Routes, Route } from "react-router-dom";
import Home from "./Home.jsx";
import FAQs from "./FAQ-feature/FAQ.jsx";
import SignInPage from "./User/Login.jsx";
import SignupForm from "./User/Signup.jsx";
import ForgotPassword from "./User/ForgotPassword.jsx";
import Page404 from './page404.jsx';
import Page404 from "./page404.jsx";
import Wishlist from "./wishlist.jsx";

import Contributors from "./Contributors.jsx";

const AllRoutes = () => {
return (
Expand All @@ -20,13 +20,13 @@ const AllRoutes = () => {
<Route exact path="/mobileAccessories" element={<Home />} />
<Route exact path="/lifestyle" element={<Home />} />

<Route exact path='/register' element={<SignupForm/>} />
<Route exact path="/login" element={<SignInPage/>} />
<Route exact path="/register" element={<SignupForm />} />
<Route exact path="/login" element={<SignInPage />} />
<Route exact path="/forgot-password" element={<ForgotPassword />} />
<Route exact path="/FAQs" element={<FAQs />} />
<Route path="*" element={<Page404 />} />
<Route exact path="/wishlist" element={<Wishlist />} />

<Route exact path="/Contributors" element={<Contributors />} />
</Routes>
</>
);
Expand Down
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

0 comments on commit 3e78e36

Please sign in to comment.