Skip to content

Commit

Permalink
components/Navbar.js: Make navbar work by upping z-values, replace sp…
Browse files Browse the repository at this point in the history
…ecialized headers with Header component
  • Loading branch information
cbrxyz committed Oct 21, 2024
1 parent 2d070ac commit 2151fdb
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 83 deletions.
10 changes: 10 additions & 0 deletions src/assets/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// assets/index.js
const images = {};

function importAll(r) {
r.keys().forEach((key) => (images[key.replace("./", "")] = r(key)));
}

importAll(require.context("./", false, /\.(png|jpe?g|svg)$/));

export default images;
26 changes: 26 additions & 0 deletions src/components/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from "react";
import background from "../assets/hawaii_resting.jpg";
import Navbar from "../components/Navbar";

function Header({ title, subTitle }) {
return (
<header
className="relative h-[667px] bg-cover bg-center"
style={{
backgroundImage: `url('${background}')`,
backgroundColor: "rgba(0, 0, 0, 0.5)",
backgroundBlendMode: "darken",
}}
>
<div className="relative z-10">
<Navbar />
</div>
<div className="absolute inset-0 flex flex-col justify-center items-center text-white">
<h1 className="text-7xl font-bold">{title}</h1>
{subTitle && <h2 className="text-3xl font-bold">{subTitle}</h2>}
</div>
</header>
);
};

export default Header;
23 changes: 17 additions & 6 deletions src/components/Navbar.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { NavLink } from 'react-router-dom';

import logo from '../assets/logo.png';

const NavItem = ({ to, label }) => {
return (
<NavLink
to={to}
className="text-white px-4 py-2 rounded transition duration-300 hover:bg-white hover:text-black"
>
{label}
</NavLink>
);
};

function Navbar() {
return (
<nav className="w-full p-6 flex justify-between items-center">
<div>
<img src={logo} alt="NaviGator AMS Logo" className="h-10" />
</div>
<ul className="flex space-x-6">
<li><Link to="/" className="text-white">Home</Link></li>
<li><Link to="/team" className="text-white">Team</Link></li>
<li><Link to="/vehicle" className="text-white">Vehicle</Link></li>
<li><Link to="/sponsors" className="text-white">Sponsors</Link></li>
<li><Link to="/photos" className="text-white">Photos</Link></li>
<NavItem to="/" label="Home" />
<NavItem to="/team" label="Team" />
<NavItem to="/vehicle" label="Vehicle" />
<NavItem to="/sponsors" label="Sponsors" />
<NavItem to="/photos" label="Photos" />
</ul>
</nav>
);
Expand Down
18 changes: 9 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React from 'react';
import {
createHashRouter,
createBrowserRouter,
RouterProvider
RouterProvider,
Link
} from 'react-router-dom';
import { createRoot } from "react-dom/client";

Expand All @@ -11,8 +12,9 @@ import ErrorPage from './pages/NotFound';
import TeamPage from './pages/Team';
import VehiclePage from './pages/Vehicle';
import SponsorsPage from './pages/Sponsors';
// import PhotosPage from './pages/Photos';
// import NotFoundPage from './pages/NotFound';
import PhotosPage from './pages/Photos';

import Navbar from "./components/Navbar.js";

const router = createBrowserRouter([
{
Expand All @@ -32,15 +34,13 @@ const router = createBrowserRouter([
path: "/sponsors",
element: <SponsorsPage />,
},
// {
// path: "/photos",
// element: <PhotosPage />,
// },
{
path: "/photos",
element: <PhotosPage />,
},
], {
});

console.log("test");

createRoot(document.getElementById("root")).render(
<RouterProvider router={router} />
);
6 changes: 5 additions & 1 deletion src/pages/Landing.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import teamPhoto from '../assets/robotx_2022_team_1.jpg';
function Header() {
return (
<header className="relative h-[667px] bg-cover bg-center" style={{ backgroundImage: `url('${background}')`, backgroundColor: 'rgba(0, 0, 0, 0.5)', backgroundBlendMode: 'darken' }}>
<Navbar />
<div className="relative z-10">
<Navbar />
</div>
<div className="absolute inset-0 flex flex-col justify-center items-center text-white">
<h1 className="text-7xl font-bold">NaviGator</h1>
<p className="text-2xl mt-2">UF's Autonomous Maritime System</p>
Expand All @@ -17,6 +19,7 @@ function Header() {
);
}

// Mission Component
function Mission() {
return (
<section className="py-8 bg-gray-300">
Expand Down Expand Up @@ -56,6 +59,7 @@ function Mission() {
);
}

// About Component
function About() {
return (
<section className="py-8 bg-gray-300">
Expand Down
89 changes: 89 additions & 0 deletions src/pages/Photos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import React, {useState} from "react";
import Header from "../components/Header";

import assets from "../assets";

const ImageSection = () => {
return (
<section className="relative max-w-6xl mx-auto py-8">
<div className="flex justify-center">
<img src={assets["teams.jpg"]} alt="teams" className="w-full object-relative rounded-lg h-relative" />
</div>
</section>
);
};

const ImageGrid = ({ openModal }) => {
const images = [
{ src: 'boat.jpg', alt: 'Boat at Sea' },
{ src: 'navigator.jpg', alt: 'Boat Preparing' },
{ src: 'navigatorams.jpg', alt: 'Testing Equipment' },
{ src: 'person.jpg', alt: 'Teamwork' },
{ src: 'hawaii_stc.jpg', alt: 'Teamwork' },
{ src: 'hawaii_dock.jpg', alt: 'Teamwork' },
{ src: 'boat_at_alumni_event-min.jpg', alt: 'Teamwork' },
{ src: 'dec_2015_trial.jpg', alt: 'Teamwork' },
];

return (
<section className="max-w-6xl mx-auto py-8 grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-4">
{images.map((image, index) => (
<div key={index} className="relative">
<img
src={assets[image.src]}
alt={image.alt}
className="w-full object-cover h-[200px] rounded-lg cursor-pointer"
onClick={() => openModal(assets[image.src])}
/>
</div>
))}
</section>
);
};


const Modal = ({ modalSrc, isVisible, closeModal }) => {
return (
<div
id="modal"
className={`fixed top-0 left-0 w-full h-full flex items-center justify-center bg-black bg-opacity-75 ${isVisible ? '' : 'hidden'}`}
>
<span className="absolute top-10 right-10 text-white text-3xl cursor-pointer" onClick={closeModal}>
&times;
</span>
<img alt="modal" src={modalSrc} className="max-w-full max-h-full object-contain" />
</div>
);
};

const PhotosPage = () => {
// This function shows hidden lines
const [modalSrc, setModalSrc] = useState('');
const [isModalVisible, setIsModalVisible] = useState(false);

// Open the modal and set the image source
const openModal = (src) => {
setModalSrc(src);
setIsModalVisible(true);
};

// Close the modal
const closeModal = () => {
setIsModalVisible(false);
};

return (
<div className="bg-gray-300" style={{ fontFamily: "Inter, sans-serif" }}>
<div className="relative">
<Header title="Photos" />
</div>
<section className="pt-20 pb-5 bg-gray-300">
<ImageSection />
<ImageGrid openModal={openModal} />
<Modal modalSrc={modalSrc} isVisible={isModalVisible} closeModal={closeModal} />
</section>
</div>
);
};

export default PhotosPage;
24 changes: 2 additions & 22 deletions src/pages/Sponsors.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
import React from "react";
import Navbar from "../components/Navbar";

import background from "../assets/hawaii_resting.jpg";

function Header() {
return (
<header
className="relative h-[667px] bg-cover bg-center"
style={{
backgroundImage: `url('${background}')`,
backgroundColor: "rgba(0, 0, 0, 0.5)",
backgroundBlendMode: "darken",
}}
>
<Navbar />
<div className="absolute inset-0 flex flex-col justify-center items-center text-white">
<h1 className="text-7xl font-bold">Sponsors</h1>
</div>
</header>
);
}
import Header from "../components/Header";

const SponsorSection = ({ title, sponsors, bgColor }) => {
return (
Expand Down Expand Up @@ -220,7 +200,7 @@ const SponsorsPage = () => {
return (
<div className="bg-gray-300" style={{ fontFamily: "Inter, sans-serif" }}>
<div className="relative">
<Header />
<Header title="Sponsors" />
</div>
<SponsorSection
title="Diamond Sponsors"
Expand Down
26 changes: 2 additions & 24 deletions src/pages/Team.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,11 @@
import React from "react";
import Navbar from "../components/Navbar";
import Header from "../components/Header";

import MemberCard from "../components/MemberCard";

import background from "../assets/hawaii_resting.jpg";
import teamPhoto from "../assets/robotx_2022_team_1.jpg";

import memberImages from "../assets/members";
import advisorImages from "../assets/advisors";

function Header() {
return (
<header
className="relative h-[667px] bg-cover bg-center"
style={{
backgroundImage: `url('${background}')`,
backgroundColor: "rgba(0, 0, 0, 0.5)",
backgroundBlendMode: "darken",
}}
>
<Navbar />
<div className="absolute inset-0 flex flex-col justify-center items-center text-white">
<h1 className="text-7xl font-bold">Meet the Team</h1>
<h2 className="text-3xl font-bold">2024 Season</h2>
</div>
</header>
);
}

const Leadership = () => {
const members = [
{ image: memberImages["cameron.jpeg"], name: 'Cameron Brown', role: 'Team Lead' },
Expand Down Expand Up @@ -86,7 +64,7 @@ const TeamPage = () => {
return (
<div className="bg-gray-300" style={{ fontFamily: "Inter, sans-serif" }}>
<div className="relative">
<Header />
<Header title="Meet the Team" subTitle="2024 Season"/>
</div>
<Leadership />
<Advisors />
Expand Down
23 changes: 2 additions & 21 deletions src/pages/Vehicle.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from "react";
import Navbar from "../components/Navbar";
import Header from "../components/Header";

import MemberCard from "../components/MemberCard";

import background from "../assets/hawaii_resting.jpg";
import cropped from "../assets/navigator_cropped_2024.png";

import settingsLogo from "../assets/settings.png";
Expand All @@ -13,24 +12,6 @@ import circuitLogo from "../assets/circuit.png";
import vrx2023 from "../assets/vrx-2023.jpg";
import testingVan from "../assets/testing_fbi_van.jpg";

function Header() {
return (
<header
className="relative h-[667px] bg-cover bg-center"
style={{
backgroundImage: `url('${background}')`,
backgroundColor: "rgba(0, 0, 0, 0.5)",
backgroundBlendMode: "darken",
}}
>
<Navbar />
<div className="absolute inset-0 flex flex-col justify-center items-center text-white">
<h1 className="text-7xl font-bold">Our Design</h1>
</div>
</header>
);
};

const NaviGatorHeader = () => {
return (
<div className="max-w-6xl mx-auto text-center">
Expand Down Expand Up @@ -379,7 +360,7 @@ const VehiclePage = () => {
return (
<div className="bg-gray-300" style={{ fontFamily: "Inter, sans-serif" }}>
<div className="relative">
<Header />
<Header title="Vehicle" />
</div>
<section className="pt-20 pb-5 bg-gray-300">
<NaviGatorHeader />
Expand Down

0 comments on commit 2151fdb

Please sign in to comment.