first commit
This commit is contained in:
51
app/page.tsx
Normal file
51
app/page.tsx
Normal file
@@ -0,0 +1,51 @@
|
||||
"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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user