PR — Ouverture automatique / create-pr (push) Successful in 4s
Scroll system - Completely reworked `useRegionScroll` controller: paginated region-by-region scroll (wheel/swipe/arrows/Home/End/Space), native scroll neutralized, regions taller than viewport split into screens, time-based rAF animation, interruption only on effective deviation. - Region resolution in 3 levels: `data-region` (single element), `data-region-children` (each direct child), `.page-snap-section` as fallback. Added `data-no-region` to exclude hero/title. - Homepage: entire MagicBento as a single region. Projects page: one stop per project (`HorizontalMotion` with `data-region-children`), category title preserved, hero excluded. - Project detail pages (ProjectPage): hero excluded from regions, media in `data-region-children`, download button as separate region. - Contact/PageShell: updated markers, removed empty zones (no forced `min-height` on `.page-snap-section`). - Removed unbounded `--region-tail` in favor of capped reserve (15vh) + merged landing spots too close to each other. - Do not re-enable native `scroll-snap-type` (Chrome proximity snap traps the user on the first region). Content - Added Ensemble Scolaire Jean XXIII project page (Défi 6e - Class Life, CRM, Inventory IT) with images, wired into the route table, the projects list, the home bento grid and the navigation menu. - Sitemap: added the missing `/projects/hinterraum` and `/projects/overclock-uprising` routes, both live in `App.tsx`. Layout & navigation - Extracted shared `PageShell` and `ProjectPage` layout components. - Navigation: more reliable scroll-to-top, footer "Co Hai Se" bold with target cursor. - ZIP download: stopped propagation + global click handler ignores download. - Various fixes (cursor, 404, layouts), typecheck/ignoreDeprecations adjusted. Docs - Consolidated into `docs/AGENTS.md` as the single source of truth; removed the redundant `docs/README.md` and `docs/ROADMAP.md`.
165 lines
4.3 KiB
TypeScript
165 lines
4.3 KiB
TypeScript
import React, {
|
|
useLayoutEffect,
|
|
useRef,
|
|
useState,
|
|
useCallback,
|
|
useMemo,
|
|
lazy,
|
|
Suspense,
|
|
} from "react";
|
|
import { Link, useNavigate, useLocation } from "react-router-dom";
|
|
import { gsap } from "gsap";
|
|
import "./CardNav.css";
|
|
|
|
import { mainMenuItems, projectMenuItems, MenuItem } from "./data/DataMenuItem";
|
|
|
|
const InfiniteMenu = lazy(
|
|
() => import("./InfiniteMenu"),
|
|
) as React.ComponentType<any>;
|
|
|
|
interface CardNavProps {
|
|
logo?: string;
|
|
logoAlt?: string;
|
|
className?: string;
|
|
ease?: string;
|
|
}
|
|
|
|
const CardNav: React.FC<CardNavProps> = ({
|
|
logo = "/images/logo.webp",
|
|
logoAlt = "Co Hai Se",
|
|
className = "",
|
|
ease = "power3.out",
|
|
}) => {
|
|
const [isHamburgerOpen, setIsHamburgerOpen] = useState<boolean>(false);
|
|
const [isExpanded, setIsExpanded] = useState<boolean>(false);
|
|
|
|
const navRef = useRef<HTMLElement>(null);
|
|
const tlRef = useRef<gsap.core.Timeline | null>(null);
|
|
|
|
const location = useLocation();
|
|
const navigate = useNavigate();
|
|
|
|
const closeMenuIfOpen = useCallback(() => {
|
|
const tl = tlRef.current;
|
|
if (!tl || !isExpanded) return;
|
|
setIsHamburgerOpen(false);
|
|
tl.reverse();
|
|
tl.eventCallback("onReverseComplete", () => setIsExpanded(false));
|
|
}, [isExpanded]);
|
|
|
|
const toggleMenu = () => {
|
|
const tl = tlRef.current;
|
|
if (!tl) return;
|
|
if (!isExpanded) {
|
|
setIsHamburgerOpen(true);
|
|
setIsExpanded(true);
|
|
tl.play();
|
|
} else {
|
|
closeMenuIfOpen();
|
|
}
|
|
};
|
|
|
|
const handleCardClick = (link: string) => {
|
|
if (!link) return;
|
|
const cleanLink = link.replace("_blank", "").trim();
|
|
if (link.includes("_blank") || cleanLink.startsWith("http")) {
|
|
window.open(cleanLink, "_blank", "noopener,noreferrer");
|
|
} else {
|
|
navigate(cleanLink);
|
|
}
|
|
closeMenuIfOpen();
|
|
};
|
|
|
|
const menuItems: MenuItem[] = useMemo(() => {
|
|
if (location.pathname.startsWith("/projects")) {
|
|
return projectMenuItems;
|
|
}
|
|
return mainMenuItems;
|
|
}, [location.pathname]);
|
|
|
|
const calculateHeight = useCallback(() => {
|
|
return window.matchMedia("(max-width: 768px)").matches
|
|
? window.innerHeight - 40
|
|
: 600;
|
|
}, []);
|
|
|
|
const createTimeline = useCallback(() => {
|
|
const navEl = navRef.current;
|
|
if (!navEl) return null;
|
|
gsap.set(navEl, { height: 60, overflow: "hidden" });
|
|
const tl = gsap.timeline({ paused: true });
|
|
tl.to(navEl, { height: calculateHeight, duration: 0.5, ease: ease });
|
|
return tl;
|
|
}, [calculateHeight, ease]);
|
|
|
|
useLayoutEffect(() => {
|
|
const tl = createTimeline();
|
|
tlRef.current = tl;
|
|
return () => {
|
|
tl?.kill();
|
|
};
|
|
}, [createTimeline]);
|
|
|
|
return (
|
|
<div className={`card-nav-container ${className}`}>
|
|
<nav ref={navRef} className={`card-nav ${isExpanded ? "open" : ""}`}>
|
|
<div className="card-nav-top">
|
|
<div
|
|
className={`hamburger-menu cursor-target ${isHamburgerOpen ? "open" : ""}`}
|
|
onClick={toggleMenu}
|
|
role="button"
|
|
tabIndex={0}
|
|
>
|
|
<div className="hamburger-line" />
|
|
<div className="hamburger-line" />
|
|
</div>
|
|
|
|
<div className="center-title-container">
|
|
<Link
|
|
onClick={closeMenuIfOpen}
|
|
to="/"
|
|
className="site-title cursor-target"
|
|
>
|
|
Esiah's Universe
|
|
</Link>
|
|
</div>
|
|
|
|
<Link
|
|
to="https://cohaise.dev"
|
|
className="right-logo-btn cursor-target"
|
|
>
|
|
<img
|
|
src={logo}
|
|
alt={logoAlt}
|
|
className="nav-logo-img"
|
|
onError={(e) => {
|
|
(e.target as HTMLImageElement).style.display = "none";
|
|
}}
|
|
/>
|
|
</Link>
|
|
</div>
|
|
|
|
<div
|
|
className="card-nav-content"
|
|
style={{
|
|
opacity: isExpanded || isHamburgerOpen ? 1 : 0,
|
|
transition: "opacity 0.3s ease 0.1s",
|
|
pointerEvents: isExpanded ? "auto" : "none",
|
|
}}
|
|
>
|
|
<Suspense fallback={null}>
|
|
<InfiniteMenu
|
|
items={menuItems as any}
|
|
scale={0.8}
|
|
onClose={closeMenuIfOpen}
|
|
onItemClick={handleCardClick}
|
|
/>
|
|
</Suspense>
|
|
</div>
|
|
</nav>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default CardNav;
|