diff --git a/components/Banner.js b/components/Banner.js index f77357cc..7d5d5d5b 100644 --- a/components/Banner.js +++ b/components/Banner.js @@ -1,11 +1,53 @@ -// components -import Hero from "@/components/common/Hero"; +import Image from "next/image"; -// services -import { Config } from "@/services/metadata/twoplaysamonth"; +// icons +import { HiArrowNarrowRight } from "react-icons/hi"; -const Banner = () => { - return ; +// image +import HeroCoders from "@/public/twoplaysamonth/HeroCoders.svg"; + +const Banner = ({ events }) => { + console.log(events); + const currentEvent = events.filter((event) => event.isCurrent); + + return ( + <> + {currentEvent.length ? ( + + + {/* primary section */} + + + + + + {currentEvent[0].name} + + {currentEvent[0].description} + + Join{" "} + + + + + + {/* image section*/} + + + + + + ) : null} + > + ); }; export default Banner; diff --git a/components/Header.js b/components/Header.js index 3e24ab4d..c116ba72 100644 --- a/components/Header.js +++ b/components/Header.js @@ -1,8 +1,9 @@ -import { useState } from "react"; +import { useEffect, useState } from "react"; import Link from "next/link"; import Image from "next/image"; import { useRouter } from "next/router"; import { AiOutlineMenu, AiOutlineClose } from "react-icons/ai"; +import ReactPlayLogo from "@/public/ReactPlayLogo.svg"; const MobileHeader = ({ links, setMobileActive, redirectToRegistration }) => { return ( @@ -34,17 +35,42 @@ const MobileHeader = ({ links, setMobileActive, redirectToRegistration }) => { ); }; -const Header = ({ links, metainfo, secondary = false }) => { +const Header = ({ links, metainfo, secondary = false, hustleHomePage }) => { const [mobileActive, setMobileActive] = useState(false); const router = useRouter(); const redirectToRegistration = () => { router.push("/hackrplay/2022/registration"); }; + const [scroll, setScroll] = useState(false); + + const controlNavbar = () => { + if (typeof window !== "undefined") { + if (window.scrollY > 100) { + // if scroll down change the background color of the navbar + setScroll(true); + } else { + // if scroll up make remove background color from navbar + setScroll(false); + } + } + }; + + useEffect(() => { + if (typeof window !== "undefined") { + window.addEventListener("scroll", controlNavbar); + + // cleanup function + return () => { + window.removeEventListener("scroll", controlNavbar); + }; + } + }, [window.scrollY]); + return ( <> {secondary ? ( - + @@ -58,21 +84,42 @@ const Header = ({ links, metainfo, secondary = false }) => { ) : ( - - + + {hustleHomePage && ( + + + + + + )} + {links && links.map((link, index) => ( - + {link.href.includes("http") ? ( {link.name} ) : ( - + {link.name} )} diff --git a/components/Hero.js b/components/Hero.js new file mode 100644 index 00000000..91e6cf55 --- /dev/null +++ b/components/Hero.js @@ -0,0 +1,47 @@ +// import React from "react"; + +import Image from "next/image"; +import Link from "next/link"; + +import HeroBanner from "@/public/hustleHomePage/HeroBanner@2x.png"; +import { Config } from "@/services/metadata/home"; + +import { HiArrowNarrowRight } from "react-icons/hi"; + +const Hero = ({ hustleHomePage }) => { + const currentEvent = Config.events.filter((event) => event.isCurrent); + + return ( + <> + {currentEvent.length === 0 && hustleHomePage && ( + <> + + + + + + An unusual place for{" "} + Extraordinary React{" "} + events + + + ReactPlay is an open-source platform to learn, crate and share + ReactJS Projects with the developer community. Start by browsing + the plays or explore the source code. + + + + View Past Events + + + + + + + > + )} + > + ); +}; + +export default Hero; diff --git a/components/Layout.js b/components/Layout.js index 9eb70573..9cb72d90 100644 --- a/components/Layout.js +++ b/components/Layout.js @@ -3,10 +3,13 @@ import Head from "next/head"; import { useRouter } from "next/router"; import Footer from "./Footer"; -import Header from "./Header"; + import Script from "next/script"; -const Layout = ({ children, title, description, metainfo }) => { +import Hero from "./Hero"; +import Header from "./Header"; + +const Layout = ({ children, title, description, metainfo, hustleHomePage }) => { const currentPath = useRouter().pathname; const [secondaryNavbar, setSecondaryNavbar] = useState(false); const [loading, setLoading] = useState(true); @@ -79,7 +82,9 @@ const Layout = ({ children, title, description, metainfo }) => { links={metainfo.links} secondary={secondaryNavbar} metainfo={metainfo} + hustleHomePage={hustleHomePage} /> + {children} diff --git a/pages/index.js b/pages/index.js index 9ef667de..d2fc17d9 100644 --- a/pages/index.js +++ b/pages/index.js @@ -2,32 +2,18 @@ import Layout from "@/components/Layout"; import Banner from "@/components/Banner"; import { Config } from "../services/metadata/home"; import MediaLayout from "@/components/MediaLayout"; -import { useEffect, useState } from "react"; -import { REACT_PLAYLIST_ID } from "config"; export default function Home() { - const [reactPlayLive, setReactPlayLive] = useState([]); - - useEffect(() => { - const getPlayListData = async () => { - const response = await fetch( - `https://www.googleapis.com/youtube/v3/playlistItems?key=${process.env.NEXT_PUBLIC_YOUTUBE_API_KEY}&part=id,snippet&maxResults=3&playlistId=${REACT_PLAYLIST_ID}` - ); - const json = await response.json(); - console.log(json); - const urls = json?.items?.map((item, index) => ({ - id: index, - src: `https://www.youtube.com/embed/${item.snippet?.resourceId?.videoId}`, - })); - setReactPlayLive(urls); - }; - getPlayListData(); - }, []); + const reactPlayLive = [ + { id: 0, src: "https://www.youtube.com/embed/1qfDkmtuWqg" }, + { id: 1, src: "https://www.youtube.com/embed/b0eas9xxD-E" }, + { id: 2, src: "https://www.youtube.com/embed/w0nd4ASTDdg" }, + ]; const EventLayout = () => { return ( - + + ); diff --git a/public/hustleHomePage/HeroBanner@2x.png b/public/hustleHomePage/HeroBanner@2x.png new file mode 100644 index 00000000..733d9041 Binary files /dev/null and b/public/hustleHomePage/HeroBanner@2x.png differ
{currentEvent[0].description}
+ ReactPlay is an open-source platform to learn, crate and share + ReactJS Projects with the developer community. Start by browsing + the plays or explore the source code. +