Merge pull request #2 from UofCBaja/header to dev

Header Merge into dev
This commit is contained in:
darkicewolf50 2024-03-13 14:34:04 -06:00 committed by GitHub
commit c9c297ffd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 131 additions and 56 deletions

View File

@ -1,20 +1,24 @@
// import OpenPage from "./OpenPage"; import OpenPageButton from "./OpenPageButton";
import { useNavigate } from "react-router-dom";
/**
* @param {null} null - Takes in nothing
* @returns {JSX.Element} JSX - HTML tags and JS functionality
* @description Drop down menu elements
* @author Brock <darkicewolf50@gmail.com>
*/
const DropdownMenu = () => { const DropdownMenu = () => {
const navigate = useNavigate(); return (
<div>
const OpenPage = (arg) => { <OpenPageButton
navigate(arg); pageToGoTo={"/JoinTheClub"}
console.log(arg); textOnButton={"Join the Club"}
}; />
<OpenPageButton
return ( pageToGoTo={"/UpcomingEvents"}
<div> textOnButton={"Upcoming Events"}
<button type = "button" onClick = {() => OpenPage('/JoinTheClub')}>Join the Club</button> />
<button type = "button" onClick = {() => OpenPage('/UpcomingEvents')}>Upcoming Events</button> </div>
</div> );
);
}; };
export default DropdownMenu; export default DropdownMenu;

View File

@ -0,0 +1,28 @@
header {
display: flex;
flex-direction: column;
margin: 1%;
margin-top: 0%;
}
figure {
margin: 0px;
height: 10%;
}
#logo {
height: 5rem;
background-color: white;
}
/* not sure what these two are for */
#title {
background-color: blueviolet;
}
.banner {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
background-color: aqua;
}

View File

@ -1,23 +1,35 @@
import logo from "./logo.png"; import logo from "./logo.png";
import DropdownMenu from "./DropdownMenu"; import DropdownMenu from "./DropdownMenu";
// import OpenPage from "./OpenPage"; import OpenPageButton from "./OpenPageButton";
import { useNavigate, Outlet } from "react-router-dom"; import { useNavigate, Outlet } from "react-router-dom";
import { useState } from "react"; import { useState } from "react";
import "./Header.css"; import "./Header.css";
export default function Header() { /**
* @param {null} null - Takes in nothing
* @returns {JSX.Element} JSX - HTML tags and JS functionality
* @description The top header part of the page includes the naviagtion
* @author Brock <darkicewolf50@gmail.com>
*/
const Header = () => {
const [isDropdownVisible, setDropdownVisible] = useState(false); const [isDropdownVisible, setDropdownVisible] = useState(false);
const navigate = useNavigate(); const navigate = useNavigate();
const OpenPage = (arg) => { /**
* @param {String} arg - The page that the button goes to
* @returns {JSX.Element} JSX - HTML tags and JS functionality
* @description Function that move you to the specified place
* @author Brock <darkicewolf50@gmail.com>
*/
const LinkTo = (arg) => {
navigate(arg); navigate(arg);
console.log(arg);
}; };
//makes the drop down menu visible when the mouse enters the Club Membership & Upcoming events button area
const handleMouseEnter = () => { const handleMouseEnter = () => {
setDropdownVisible(true); setDropdownVisible(true);
}; };
//makes the drop down menu invisible when the mouse leaves the Club Membership & Upcoming events button area
const handleMouseLeave = () => { const handleMouseLeave = () => {
setDropdownVisible(false); setDropdownVisible(false);
}; };
@ -25,51 +37,52 @@ export default function Header() {
return ( return (
<> <>
<header> <header>
<div> <figure>
<img <img
style={{ background: "gray" }} id="logo"
onClick={() => OpenPage("/")} onClick={() => LinkTo("/")}
src={logo} src={logo}
alt="logo" alt="Schulich Off-Road's logo"
/>
<figcaption>
<h2>Schulich Offroad</h2>
</figcaption>
</figure>
<nav>
<OpenPageButton
pageToGoTo={"/"}
textOnButton={"About Us"}
/>
<OpenPageButton
pageToGoTo={"/Teams"}
textOnButton={"Teams"}
/>
<OpenPageButton
pageToGoTo={"/OurSponsors"}
textOnButton={"Our Sponsors"}
/>
<OpenPageButton
pageToGoTo={"/BecomeASponsor"}
textOnButton={"Become a Sponsor"}
/> />
<p>Schulich Offroad</p>
</div>
<div>
<button
type="button"
onClick={() => OpenPage("/")}>
About Us
</button>
<button
type="button"
onClick={() => OpenPage("/Teams")}>
Teams
</button>
<button
type="button"
onClick={() => OpenPage("/OurSponsors")}>
Our Sponsors
</button>
<button
type="button"
onClick={() => OpenPage("/BecomeASponsor")}>
Become a Sponsor
</button>
<div <div
onMouseEnter={handleMouseEnter} onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave} onMouseLeave={handleMouseLeave}
style={{ background: "red" }}> style={{ background: "red" }}>
<button type="button">Club Membership & Upcoming Events</button> {/* dropdown menu is only visible when a mouse enters the area of the button below */}
<button type="button">Club Membership & Upcoming Events</button>{" "}
{/*this button does nothing yet*/}
{isDropdownVisible && <DropdownMenu />} {isDropdownVisible && <DropdownMenu />}
</div> </div>
<button <OpenPageButton
type="button" pageToGoTo={"/Gallery"}
onClick={() => OpenPage("/Gallery")}> textOnButton={"Gallery"}
Gallery />
</button> </nav>
</div>
</header> </header>
<Outlet /> <Outlet />
</> </>
); );
} };
export default Header;

View File

@ -0,0 +1,3 @@
#navigateButton {
text-decoration: none;
}

View File

@ -0,0 +1,27 @@
import { useNavigate } from "react-router-dom";
import "./OpenPageButton.css";
/**
* @param {String} pageToGoTo - The page that the button goes to
* @param {String} textOnButton - The Text tht will be on the button
* @returns {JSX.Element} JSX - HTML tags and JS functionality
* @description Button Template that moves you to the
* @author Brock <darkicewolf50@gmail.com>
* @todo refactor so that name is OpenPageButton, add css to the button
*/
const OpenPageButton = ({ pageToGoTo, textOnButton }) => {
const navigate = useNavigate();
const navigateTo = (param) => {
navigate(param);
};
return (
<button
id="navigateButton"
onClick={() => navigateTo(pageToGoTo)}>
{textOnButton}
</button>
);
};
export default OpenPageButton;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 38 KiB