Skip to content

Commit

Permalink
Merge pull request #665 from ayush-848/master
Browse files Browse the repository at this point in the history
Added Our Contributors page
  • Loading branch information
thestarsahil authored Jun 18, 2024
2 parents 00782d7 + 9eae659 commit e1ca668
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 30 deletions.
69 changes: 69 additions & 0 deletions src/components/Contributors/Contribute.css
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;
}
74 changes: 74 additions & 0 deletions src/components/Contributors/Contribute.jsx
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;
51 changes: 30 additions & 21 deletions src/components/Dashboard/Dashboard.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState, useCallback } from "react";
import "./Dashboard.css";
import { useNavigate, NavLink, Link } from "react-router-dom";
import { useNavigate, NavLink, Link, useLocation } from "react-router-dom";
import Logo from "../../assets/logo.webp";
import { signOut, onAuthStateChanged } from "firebase/auth";
import { auth } from "../../firebase/auth";
Expand All @@ -10,30 +10,34 @@ import ScrollToTop from "react-scroll-to-top";
import { ToastContainer, toast } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
import CollegeCard from "./CollegeCard";
import FAQS from "../FAQs/FAQS";
import FAQs from '../FAQs/FAQs';


const Dashboard = () => {
const navigate = useNavigate();
const location = useLocation();
const [menuOpen, setMenuOpen] = useState(false);
const [searchTerm, setSearchTerm] = useState("");
const [filteredColleges, setFilteredColleges] = useState(collegesData);

useEffect(() => {
auth.onAuthStateChanged((user) => {
if (user) {
toast.success("Logged in! 🚀",{
className: "toast-message",
})
});
console.log("");
} else if (!user) {
toast.success("Logged out!",{
className: "toast-message",
})
});
setTimeout(() => {
navigate("/");
}, 1000);
}
});
}, []);

useEffect(() => {
const results = collegesData.filter(
(college) =>
Expand All @@ -43,6 +47,15 @@ const Dashboard = () => {
setFilteredColleges(results);
}, [searchTerm]);

useEffect(() => {
if (location.hash === "#faqs1") {
const faqsElement = document.getElementById("faqs1");
if (faqsElement) {
faqsElement.scrollIntoView({ behavior: "smooth" });
}
}
}, [location]);

const handleSignOut = useCallback(() => {
signOut(auth)
.then(() => {
Expand Down Expand Up @@ -71,6 +84,7 @@ const Dashboard = () => {
const handleSearchChange = useCallback((e) => {
setSearchTerm(e.target.value);
}, []);

const [activeIndex, setActiveIndex] = useState(null);

const handleTouchStart = (index) => {
Expand All @@ -81,26 +95,21 @@ const Dashboard = () => {
setActiveIndex(null);
};

const [fix, setFix] = useState(false);



const [fix, setFix]= useState(false)
//function for appearance of background for nav menu
function setFixed(){
if(window.scrollY>0){
setFix(true)
}else{
setFix(false)
}
}
const setFixed = () => {
if (window.scrollY > 0) {
setFix(true);
} else {
setFix(false);
}
};

window.addEventListener("scroll", setFixed)
window.addEventListener("scroll", setFixed);

return (
//scrolltotop is for scroll to top widget
//Then the navbar code begins
<main>
<div className="scroll">
<main>
<div className="scroll">
<ScrollToTop
smooth
viewBox="0 0 24 24"
Expand Down Expand Up @@ -202,7 +211,7 @@ window.addEventListener("scroll", setFixed)
</div>
))}
</div>
<FAQS/>
<FAQs/>
<Footer />
</main>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// FAQs.jsx

import React, { useState } from 'react';
import './FAQs.css';

Expand Down Expand Up @@ -31,7 +30,7 @@ const FAQs = () => {
};

return (
<div className="faqs-container">
<div id="faqs" className="faqs-container">
<h2>Frequently Asked Questions</h2>
<div className="accordion">
{faqs.map((faq, index) => (
Expand Down
42 changes: 37 additions & 5 deletions src/components/Footer/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ function Footer() {
</a>
</li>
<li>Blog</li>
<li>Help</li>
<li>
<a
style={{ textDecoration: "none", color: "inherit" }}
href="./FAQs"
>
FAQs
</a>
</li>
<li>Privacy</li>
<li>Terms</li>
<li>
Expand All @@ -26,7 +33,14 @@ function Footer() {
Contact
</a>
</li>
<li>Our Countributors</li>
<li>
<a
style={{ textDecoration: "none", color: "inherit" }}
href="./contribute"
>
Our Contributors
</a>
</li>
<li>Join Us</li>
</ul>
<p>© 2023 Counsellor</p>
Expand All @@ -38,9 +52,27 @@ function Footer() {
>
<FaGithub />
</a>
<FaFacebook />
<FaInstagram />
<FaLinkedin />
<a
href="https://facebook.com"
target="_blank"
rel="noreferrer"
>
<FaFacebook />
</a>
<a
href="https://instagram.com"
target="_blank"
rel="noreferrer"
>
<FaInstagram />
</a>
<a
href="https://linkedin.com"
target="_blank"
rel="noreferrer"
>
<FaLinkedin />
</a>
</div>
</div>
</footer>
Expand Down
6 changes: 4 additions & 2 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import ForgotPasswordForm from "./ForgotPassword/ForgotPassword.jsx";
import LoginForm from './Login/Login.jsx';
import Navbar from "./Navbar/Navbar.jsx";
import SignUpForm from './SignUp/SignUp.jsx';
import FAQs from './FAQs/FAQS.jsx'
import FAQs from './FAQs/FAQs.jsx'
import Contribute from "./Contributors/Contribute.jsx";

const Home = lazy(() => import("./Home/Home.jsx"));
const About = lazy(() => import("./About/About.jsx"));
Expand All @@ -17,6 +18,7 @@ export {
LoginForm,
Navbar,
SignUpForm,
FAQs
FAQs,
Contribute
};

6 changes: 6 additions & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ForgotPasswordForm,
SignUpForm,
FAQs,
Contribute,
} from "./components/index";
import Loading from "./components/Loading/Loading";
import Login from "./components/Login/Login";
Expand Down Expand Up @@ -77,6 +78,11 @@ const router = createBrowserRouter([
errorElement: <ErrorPage />,
element: <FAQs />,
},
{
path: "/Contribute",
errorElement: <ErrorPage />,
element: <Contribute />,
}
],
},
]);
Expand Down

0 comments on commit e1ca668

Please sign in to comment.