Files
Portfolio/app/page.tsx
2026-01-22 20:55:07 +00:00

52 lines
1.3 KiB
TypeScript

"use client";
import { useState } from "react";
import Nav from "./components/Nav";
import Projects from "./components/Projects";
import Info from "./components/Info";
import Contact from "./components/Contact";
import styles from "./page.module.css";
type OpenWindow = "projects" | "info" | "contact" | null;
export default function Home() {
const [openWindow, setOpenWindow] = useState<OpenWindow>(null);
const handleNavClick = (e: React.MouseEvent<HTMLDivElement>) => {
const icon = (e.target as HTMLElement).closest("a");
if (!icon) return;
e.preventDefault();
const icons = Array.from(
e.currentTarget.querySelectorAll("a")
);
const index = icons.indexOf(icon);
const windowByIndex: Record<number, OpenWindow> = {
0: "projects",
1: "info",
2: "contact",
};
const nextWindow = windowByIndex[index] ?? null;
setOpenWindow(prev =>
prev === nextWindow ? null : nextWindow
);
};
return (
<div className={styles.main}>
<div className={styles.nav} onClick={handleNavClick}>
<Nav/>
</div>
<div style={{flex: 1}}>
{openWindow === "projects" && <Projects />}
{openWindow === "info" && <Info />}
{openWindow === "contact" && <Contact />}
</div>
</div>
);
}