Skip to content

Commit

Permalink
Merge pull request #252 from MastanSayyad/mains
Browse files Browse the repository at this point in the history
Create "Our Contributors" Page for the website
  • Loading branch information
Trisha-tech authored Aug 10, 2024
2 parents 4c9494b + f97ccd0 commit ac6e6f8
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 45 deletions.
8 changes: 4 additions & 4 deletions client/package-lock.json

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

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.7.2",
"axios": "^1.7.3",
"lottie-react": "^2.4.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
78 changes: 38 additions & 40 deletions client/src/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import "./App.css";
// import {Outlet} from "react-router-dom";
import React, { useState, useEffect } from 'react';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import './App.css';
import './Animations.css';
import { Navbar, Footer } from './Components/index.js';
import { ProfilePage, Product } from './Components/index';
import LoginPage from './Pages/LoginPage.jsx';
Expand All @@ -11,16 +11,15 @@ import Orders from './Pages/Orders.jsx';
import Wishlist from './Pages/Wishlist.jsx';
import HomePage from './Pages/Home.jsx';
import Shop from "./Pages/Shop.jsx";
import { Toast } from "./Toast/Toast.js";
import Contact from "./Pages/Contact.jsx";
import PrivacyPolicy from "./Pages/PrivacyPolicy.jsx";
import TermsAndConditions from "./Pages/Terms.jsx";
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import './Animations.css';
import FAQ from "./Pages/Faq.jsx";
import AboutUs from "./Pages/AboutUs.jsx";
import { OrderList } from './Pages/Orders.jsx';
import Contributors from "./Pages/Contributors.jsx";
import Preloader from "./Components/Preloader.jsx";
import { Toast } from "./Toast/Toast.js";
import GoToTop from "./Components/GoToTop.jsx";
import License from "./Pages/Licensing.jsx";

Expand All @@ -32,47 +31,46 @@ function App() {
};

useEffect(() => {
if (darkMode) {
document.body.classList.add("dark")
} else {
document.body.classList.remove("dark")
}
document.body.classList.toggle("dark", darkMode);
}, [darkMode]);

const appStyle = {
backgroundColor: darkMode ? '#333' : '#f4f4f4',
// borderRadius: '8px',
};

return (
<>
<Router>
<div className="App" style={appStyle}>
<Navbar darkMode={darkMode} toggleDarkMode={toggleDarkMode} />
<Routes>
<Route path="/" exact element={<HomePage darkMode={darkMode} />} />
<Route path="/shop" exact element={<Shop />} />
<Route path="/shop/:id" element={<Product />} />
<Route path="/login" element={<LoginPage />} />
<Route path="/signup" element={<SignUpPage />} />
<Route path="/wishlist" element={<Wishlist />} />
<Route path="/cart" element={<Cart />} />
<Route path="/orders" element={<OrderList />} />
<Route path="/contactus" element={<Contact />} />
<Route path="/about" element={<AboutUs/>}/>
<Route path="/faqs" element={<FAQ/>}/>
<Route path="/privacy" element={<PrivacyPolicy />}/>
<Route path="/licensing" element={<License />}/>
<Route path="/terms" element={<TermsAndConditions />}/>
</Routes>
<Toast position="bottom-right" />
<Footer />
<Preloader/>
<GoToTop />
</div>
</Router>
</>
<Router>
<div className="App" style={appStyle}>
<Navbar darkMode={darkMode} toggleDarkMode={toggleDarkMode} />
<Routes>
<Route path="/" element={<HomePage darkMode={darkMode} />} />
<Route path="/shop" element={<Shop />} />
<Route path="/shop/:id" element={<Product />} />
<Route path="/login" element={<LoginPage />} />
<Route path="/signup" element={<SignUpPage />} />
<Route path="/wishlist" element={<Wishlist />} />
<Route path="/cart" element={<Cart />} />
<Route path="/orders" element={<OrderList />} />
<Route path="/contactus" element={<Contact />} />
<Route path="/about" element={<AboutUs />} />
<Route path="/faqs" element={<FAQ />} />
<Route path="/privacy" element={<PrivacyPolicy />} />
<Route path="/licensing" element={<License />} />
<Route path="/terms" element={<TermsAndConditions />} />
<Route path="/contributors" element={<Contributors />} />
<Route path="*" element={<NotFound />} /> {/* Fallback route */}
</Routes>
<Toast position="bottom-right" />
<Footer />
<Preloader /> {/* Ensure Preloader is correctly styled */}
<GoToTop /> {/* Added GoToTop component */}
</div>
</Router>
);
}

export default App;
function NotFound() {
return <h1>404 Not Found</h1>;
}

export default App;
2 changes: 2 additions & 0 deletions client/src/Components/Footer/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ function Footer() {
<li><Link to="/about" className="hover:text-yellow-300 text-lg">About us</Link></li>
<li><Link to="/" className="hover:text-yellow-300 text-lg">Careers</Link></li>
<li><Link to="/" className="hover:text-yellow-300 text-lg">Gift Cards</Link></li>
<li><Link to="/contributors" className="hover:text-yellow-300 text-lg">Our Contributors</Link></li>

</ul>
</div>
<div className="footer-section">
Expand Down
141 changes: 141 additions & 0 deletions client/src/Pages/Contributors.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
.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: #0077b6;
font-size: 2.5rem;
font-weight: bold;
margin-bottom: 2rem;
text-transform: uppercase;
}

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

.contributor-card {
position: relative;
width: 100%;
max-width: 25%;
display: flex;
flex-direction: column;
align-items: center;
background-color: rgb(0,0,85);
border: 1px solid #6969ff;
border-radius: 0.5rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
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(5, 205, 208, 0.752);
}

.contributor-card:hover p {
text-shadow: 1px 1px 2px rgb(0, 225, 255), 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(237, 9, 176, 0.926), 0 0 0.2em rgb(0, 191, 255), 0 0 0.8em rgb(135, 206, 235);
color: white;
font-size: 1.04rem;
font-weight: 600;
text-decoration: wavy;
}

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

.contributor-card::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(152deg, #0077b6 50%, #023e8a 50%);
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 {
transform: translate(0, 0);
opacity: 1;
}


.contributor-link {
display: block;
}

.contributor-avatar {
width: 5rem;
height: 5rem;
border-radius: 50%;
object-fit: cover;
margin-bottom: 1rem;
border: 2px solid #00b4d8;
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: #f3f4f6;
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: #d1d5db;
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%;
}
}
90 changes: 90 additions & 0 deletions client/src/Pages/Contributors.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import React, { useEffect, useState } from 'react';
import axios from 'axios';
import './Contributors.css';
import Preloader from '../Components/Preloader';

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

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

try {
while (true) {
const response = await axios.get(
`https://api.github.com/repos/Trisha-tech/OnlineBookSales/contributors`,
{
params: {
per_page: 100,
page,
},
}
);
const data = response.data;
if (data.length === 0) {
break;
}
allContributors = [...allContributors, ...data];
page++;
}
setContributors(allContributors);
} catch (error) {
console.error('Error fetching contributors:', error.message);
setError('Failed to load contributors. Please try again later.'); // Set error message
} finally {
setLoading(false);
}
}
fetchContributors();
}, []);

if (loading) {
return <Preloader />; // Show preloader while loading
}

if (error) {
return (
<div className="error-message">
<p>{error}</p>
</div>
); // Show error message if there's an error
}

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}
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;

0 comments on commit ac6e6f8

Please sign in to comment.