From 3cf35b8bb047ea5d2a328b08723e7ffeabe580be Mon Sep 17 00:00:00 2001 From: Vaibhav Babele Date: Tue, 14 Jan 2025 00:41:51 +0530 Subject: [PATCH 1/2] ADD CONTRIBUTOR PAGE AND LINK IN FOOTER --- src/App.js | 2 + src/Pages/contributor.js | 189 +++++++++++++++++++++++++++++++ src/componets/Navitems.js | 226 +++++++++++++++++++------------------- src/componets/footer.js | 1 + 4 files changed, 305 insertions(+), 113 deletions(-) create mode 100644 src/Pages/contributor.js diff --git a/src/App.js b/src/App.js index 8b45bc0..512f082 100644 --- a/src/App.js +++ b/src/App.js @@ -14,6 +14,7 @@ import Register from './Pages/Register'; import Shop from './Pages/Shop'; import Cart from './Pages/cart'; import About from './Pages/About'; +import Contributor from './Pages/contributor'; import Faq from './Pages/Faq'; import Contact from './Pages/contact'; import Profile from './Pages/profile'; @@ -59,6 +60,7 @@ function App() { } /> } /> } /> + } /> } /> } /> } /> diff --git a/src/Pages/contributor.js b/src/Pages/contributor.js new file mode 100644 index 0000000..1f57095 --- /dev/null +++ b/src/Pages/contributor.js @@ -0,0 +1,189 @@ +import React, { useEffect, useState } from "react"; +import styled from "styled-components"; +import { motion } from "framer-motion"; + +// Replace these with your repository details +const REPO_OWNER = "Mujtabaa07"; +const REPO_NAME = "coffeeShop"; +const GITHUB_TOKEN = ""; // Optional: Add your GitHub personal access token to avoid rate limits + +// Function to fetch contributors for a specific page +const fetchContributors = async (page, setContributors, setError) => { + try { + const response = await fetch( + `https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/contributors?page=${page}&per_page=20`, + { + headers: GITHUB_TOKEN ? { Authorization: `token ${GITHUB_TOKEN} `} : {}, + } + ); + + if (!response.ok) throw new Error("Failed to fetch contributors"); + + const contributors = await response.json(); + setContributors(contributors); + setError(false); // No error + } catch (error) { + console.error("Error fetching contributors:", error); + setContributors([]); + setError(true); // Set error state + } +}; + +const ContributorContainer = styled.div` + padding: 6rem 2rem; + max-width: 1900px; + margin: 0 auto; + background-color: #fffbeb; + background-image: url("https://png.pngtree.com/thumb_back/fh260/background/20231205/pngtree-creamy-textured-milk-colored-background-image_13815875.png"); + background-size: cover; + background-position: center; + border-radius: 12px; +`; + +const Title = styled(motion.h1)` + font-size: 3rem; + margin-bottom: 3rem; + text-align: center; + color: #7c2214; + font-weight: bold; + text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); +`; + +const ContributorsGrid = styled.div` + display: grid; + grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); + gap: 20px; + justify-items: center; + align-items: center; +`; + +const ContributorCard = styled.div` + align-items: center; + justify-content: center; + background: #ffffff; + color: #333; + border-radius: 15px; + padding: 20px; + width: 250px; + box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1); + text-align: center; + transition: transform 0.3s ease, box-shadow 0.3s ease; + + &:hover { + transform: translateY(-10px); + box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2); + } + + img { + + width: 100px; + height: 100px; + border-radius: 50%; + border: 3px solid #ffcc00; + margin-bottom: 15px; + } + + h3 { + font-size: 1.4rem; + margin: 10px 0; + } + + a { + color: #ffcc00; + font-weight: bold; + text-decoration: none; + transition: color 0.3s ease; + + &:hover { + color: #004e64; + } + } +`; + +const PaginationControls = styled.div` + display: flex; + justify-content: center; + margin-top: 20px; + + button { + background: #004e64; + color: white; + padding: 10px 20px; + border: none; + border-radius: 5px; + margin: 0 5px; + cursor: pointer; + font-size: 1rem; + transition: background 0.3s ease; + + &:hover { + background: #007f8a; + } + + &:disabled { + background: #ccc; + cursor: not-allowed; + } + } +`; + +const Contributor = () => { + const [contributors, setContributors] = useState([]); // State for contributors + const [currentPage, setCurrentPage] = useState(1); // State for current page + const [error, setError] = useState(false); // Error state + + useEffect(() => { + fetchContributors(currentPage, setContributors, setError); + }, [currentPage]); // Re-fetch contributors when the page changes + + const handleNextPage = () => setCurrentPage((prev) => prev + 1); + const handlePrevPage = () => setCurrentPage((prev) => (prev > 1 ? prev - 1 : 1)); + + return ( + + + Meet Our Contributors + + {error ? ( +

+ Failed to load contributors. Please try again later. +

+ ) : ( + <> + + {contributors.map((contributor) => ( + + {`Avatar +

{contributor.login}

+ + GitHub Profile + +
+ ))} +
+ + + + + + )} +
+ ); +}; + +export default Contributor; \ No newline at end of file diff --git a/src/componets/Navitems.js b/src/componets/Navitems.js index e9fefd5..849a11d 100644 --- a/src/componets/Navitems.js +++ b/src/componets/Navitems.js @@ -1,113 +1,113 @@ -export const navItems = [ - { - id: 1, - title: "Home", - path: "./", - cName: "nav-item", - }, - { - id: 2, - title: "About", - path: "./About", - cName: "nav-item", - }, - { - id: 3, - title: "Product", - path: "./product", - cName: "nav-item", - }, - { - id: 4, - title: "Contact", - path: "./contact", - cName: "nav-item", - }, - { - id: 5, - title: "Stories", - path: "./our-story", - cName: "nav-item", - }, - { - id: 6, - title: "User", - path: "./user", - cName: "nav-item", - }, - { - id :6, - title:"About", - path:"./about", - cName:"nav-item", - }, - -]; - -export const productDropdown = [ - { - id: 1, - title: "Shop", - path: "./shop", - cName: "submenu-item", - }, - - { - id: 2, - title: "Premium Beans", - path: "./premiumBeans", - cName: "submenu-item", - }, - - { - id: 3, - title: "Expert Baristas", - path: "./expertbaristas", - cName: "submenu-item", - }, -]; - -export const ourstoryDropdown = [ - { - id: 1, - title: "About", - path: "./about", - cName: "submenu-item", - }, - { - id: 2, - title: "Testimonials", - path: "./testimonial", - cName: "submenu-item", - }, -]; - -export const userLogoutDropdown = [ - { - id: 1, - title: "Login", - path: "./login", - cName: "submenu-item", - }, - { - id: 2, - title: "Register", - path: "./register", - cName: "submenu-item", - }, -]; - -export const userLoginDropdown = [ - { - id: 1, - title: "Cart", - path: "./cart", - cName: "submenu-item", - }, - { - id: 2, - title: "Profile", - path: "./profile", - cName: "submenu-item", - }, -]; +export const navItems = [ + { + id:1, + title:"Home", + path:"./", + cName:"nav-item", + }, + { + id:2, + title:"Product", + path:"./product", + cName:"nav-item", + }, + + + + { + id:3, + title:"Contact", + path:"./contact", + cName:"nav-item", + }, + + { + id:4, + title:"Stories", + path:"./our-story", + cName:"nav-item", + }, + + { + id:5, + title:"User", + path:"./user", + cName:"nav-item", + }, +]; + +export const productDropdown =[ + { + id:1, + title:"Shop", + path:"./shop", + cName:"submenu-item", + }, + + { + id:2, + title:"Premium Beans", + path:"./premiumBeans", + cName:"submenu-item", + }, + + { + id:3, + title:"expert bistas", + path:"./expertbaristas", + cName:"submenu-item", + }, +]; + +export const ourstoryDropdown =[ + { + id:1, + title:"about", + path:"./about", + cName:"submenu-item", + }, + + { + id:2, + title:"testimonials", + path:"./testimonial", + cName:"submenu-item", + }, + + +]; + +export const userLogoutDropdown =[ + { + id:1, + title:"login", + path:"./login", + cName:"submenu-item", + }, + + { + id:2, + title:"register", + path:"./register", + cName:"submenu-item", + }, +]; + +export const userLoginDropdown =[ + { + id:1, + title:"cart", + path:"./cart", + cName:"submenu-item", + }, + + { + id:2, + title:"profile", + path:"./profile", + cName:"submenu-item", + }, + + +]; + diff --git a/src/componets/footer.js b/src/componets/footer.js index f028651..d7db706 100644 --- a/src/componets/footer.js +++ b/src/componets/footer.js @@ -175,6 +175,7 @@ function Footer() { About Contact Testimonial + Contributors From dcf2fde1c49c0a27003c11efcc052a292b87cba6 Mon Sep 17 00:00:00 2001 From: Vaibhav Babele <144267863+VAIBHAVBABELE@users.noreply.github.com> Date: Sat, 18 Jan 2025 11:47:28 +0530 Subject: [PATCH 2/2] Delete src/componets/Navitems.js --- src/componets/Navitems.js | 214 -------------------------------------- 1 file changed, 214 deletions(-) delete mode 100644 src/componets/Navitems.js diff --git a/src/componets/Navitems.js b/src/componets/Navitems.js deleted file mode 100644 index cce7179..0000000 --- a/src/componets/Navitems.js +++ /dev/null @@ -1,214 +0,0 @@ -export const navItems = [ - { - id:1, - title:"Home", - path:"./", - cName:"nav-item", - }, - { - id:2, - title:"Product", - path:"./product", - cName:"nav-item", - }, - - - - { - id:3, - title:"Contact", - path:"./contact", - cName:"nav-item", - }, - - { - id:4, - title:"Stories", - path:"./our-story", - cName:"nav-item", - }, - - { - id:5, - title:"User", - path:"./user", - cName:"nav-item", - }, -]; -export const productDropdown =[ - { - id:1, - title:"Shop", - path:"./shop", - cName:"submenu-item", - }, - - { - id:2, - title:"Premium Beans", - path:"./premiumBeans", - cName:"submenu-item", - }, - - { - id:3, - title:"expert bistas", - path:"./expertbaristas", - cName:"submenu-item", - }, -]; -export const ourstoryDropdown =[ - { - id:1, - title:"about", - path:"./about", - cName:"submenu-item", - }, - - { - id:2, - title:"testimonials", - path:"./testimonial", - cName:"submenu-item", - }, - - -]; -export const userLogoutDropdown =[ - { - id:1, - title:"login", - path:"./login", - cName:"submenu-item", - }, - - { - id:2, - title:"register", - path:"./register", - cName:"submenu-item", - }, -]; -export const userLoginDropdown =[ - { - id:1, - title:"cart", - path:"./cart", - cName:"submenu-item", - }, - - { - id:2, - title:"profile", - path:"./profile", - cName:"submenu-item", - }, - - -]; -export const navItems = [ - { - id: 1, - title: "Home", - path: "./", - cName: "nav-item", - }, - { - id: 2, - title: "About", - path: "./About", - cName: "nav-item", - }, - { - id: 3, - title: "Product", - path: "./product", - cName: "nav-item", - }, - { - id: 4, - title: "Contact", - path: "./contact", - cName: "nav-item", - }, - { - id: 5, - title: "Stories", - path: "./our-story", - cName: "nav-item", - }, - { - id: 6, - title: "User", - path: "./user", - cName: "nav-item", - }, - -]; -export const productDropdown = [ - { - id: 1, - title: "Shop", - path: "./shop", - cName: "submenu-item", - }, - - { - id: 2, - title: "Premium Beans", - path: "./premiumBeans", - cName: "submenu-item", - }, - - { - id: 3, - title: "Expert Baristas", - path: "./expertbaristas", - cName: "submenu-item", - }, -]; -export const ourstoryDropdown = [ - { - id: 1, - title: "About", - path: "./about", - cName: "submenu-item", - }, - { - id: 2, - title: "Testimonials", - path: "./testimonial", - cName: "submenu-item", - }, -]; -export const userLogoutDropdown = [ - { - id: 1, - title: "Login", - path: "./login", - cName: "submenu-item", - }, - { - id: 2, - title: "Register", - path: "./register", - cName: "submenu-item", - }, -]; -export const userLoginDropdown = [ - { - id: 1, - title: "Cart", - path: "./cart", - cName: "submenu-item", - }, - - { - id: 2, - title: "Profile", - path: "./profile", - cName: "submenu-item", - }, - -]; -