From 7c3bd72fa0dd26e7aca54f5499d1c4217543ad17 Mon Sep 17 00:00:00 2001 From: Timothy Pidashev Date: Tue, 19 Mar 2024 21:17:00 -0700 Subject: [PATCH] Split up header into multiple readable parts --- src/web/src/app/page.jsx | 2 +- src/web/src/components/header.jsx | 141 +++++++++++++++++------------- src/web/src/components/hero.jsx | 3 +- 3 files changed, 81 insertions(+), 65 deletions(-) diff --git a/src/web/src/app/page.jsx b/src/web/src/app/page.jsx index 77ab05e..dc253a1 100644 --- a/src/web/src/app/page.jsx +++ b/src/web/src/app/page.jsx @@ -6,6 +6,6 @@ import { HeroSection1, HeroSection2, HeroSection3 } from "@/components/hero"; // Exports export default function Index() { return ( - +
); } diff --git a/src/web/src/components/header.jsx b/src/web/src/components/header.jsx index 60c9802..31e41af 100644 --- a/src/web/src/components/header.jsx +++ b/src/web/src/components/header.jsx @@ -1,12 +1,11 @@ "use client"; -import ThemeToggle from "@/components/theme-toggle" +import { useState, useEffect } from "react"; import Link from "next/link"; import { motion, AnimatePresence } from "framer-motion"; -import { useState, useEffect } from "react"; - -let tabs = [ +// Tabs(links to be converted into a tab menu) +const tabs = [ { id: "/", label: "Home", color: "green" }, { id: "projects", label: "Projects", color: "yellow" }, { id: "resume", label: "Resume", color: "blue" }, @@ -14,17 +13,84 @@ let tabs = [ { id: "shop", label: "Shop", color: "aqua" } ]; +// Tab theme colors const tabColors = { - "green": "bg-light-green-1 dark:bg-dark-green-1", - "yellow": "bg-light-yellow-1 dark:bg-dark-yellow-1", - "blue": "bg-light-blue-1 dark:bg-dark-blue-1", - "purple": "bg-light-purple-1 dark:bg-dark-purple-1", - "aqua": "bg-light-aqua-1 dark:bg-dark-aqua-1" + green: "bg-light-green-1 dark:bg-dark-green-1", + yellow: "bg-light-yellow-1 dark:bg-dark-yellow-1", + blue: "bg-light-blue-1 dark:bg-dark-blue-1", + purple: "bg-light-purple-1 dark:bg-dark-purple-1", + aqua: "bg-light-aqua-1 dark:bg-dark-aqua-1" +}; + +// Individual tab links +function Tab({ tab, activeTab, setActiveTab }) { + return ( + + setActiveTab(tab.id)} + className={`${ + activeTab === tab.id ? "" : "" + } + relative rounded-full + lg:px-6 md:px-5 sm:px-4 lg:py-1.5 md:py-1.5 sm:py-1.5 + lg:mr-8 md:mr-4 sm:mr-2 lg:mb-1 md:mb-1 sm:mb-1 + lg:text-4xl md:text-3xl sm:text-2xl font-bold text-light-foreground dark:text-dark-foreground + transition-all focus-visible:outline-2 + `} + style={{ + WebkitTapHighlightColor: "transparent" + }} + variants={{ + visible: { opacity: 1, x: 0 }, + hidden: { opacity: 0, x: -50 } + }} + transition={{ duration: 0.3 }} + > + {activeTab === tab.id && ( + + )} + {tab.label} + + + ); +} + +// List of tabs +function TabMenu({ tabs, activeTab, setActiveTab }) { + return ( + + {tabs.map((tab) => ( + + ))} + + ); } function Header() { const [mounted, setMounted] = useState(false); - let [activeTab, setActiveTab] = useState(tabs[0].id); + const [activeTab, setActiveTab] = useState(tabs[0].id); useEffect(() => { setMounted(true); @@ -34,62 +100,11 @@ function Header() {
{mounted && ( - - {tabs.map((tab, index) => ( - - setActiveTab(tab.id)} - className={`${ - activeTab === tab.id ? "" : "" - } - relative rounded-full - lg:px-6 md:px-5 sm:px-4 lg:py-1.5 md:py-1.5 sm:py-1.5 - lg:mr-8 md:mr-4 sm:mr-2 lg:mb-1 md:mb-1 sm:mb-1 - lg:text-4xl md:text-3xl sm:text-2xl font-bold text-light-foreground dark:text-dark-foreground - transition-all focus-visible:outline-2 - `} - style={{ - WebkitTapHighlightColor: "transparent", - }} - variants={{ - visible: { opacity: 1, x: 0 }, - hidden: { opacity: 0, x: -50 } - }} - transition={{ duration: 0.3 }} - > - {activeTab === tab.id && ( - - )} - {tab.label} - - - ))} - + )}
); } + export default Header; diff --git a/src/web/src/components/hero.jsx b/src/web/src/components/hero.jsx index 01c3822..f5dbc2b 100644 --- a/src/web/src/components/hero.jsx +++ b/src/web/src/components/hero.jsx @@ -1,4 +1,5 @@ -use client"; +"use client" + import { Suspense, useMemo } from "react"; import { Canvas } from "@react-three/fiber"; import { motion, AnimatePresence } from "framer-motion";