feat: implement CardNav component with responsive design and animations

This commit is contained in:
2026-03-29 22:18:01 +02:00
parent 6a2bbecc84
commit 3f6cdd7cf1
5 changed files with 61 additions and 37 deletions
+1 -2
View File
@@ -83,11 +83,10 @@
display: flex;
align-items: center;
justify-content: center;
pointer-events: none; /* Laisse cliquer au travers si besoin */
pointer-events: none;
}
.site-title {
/* Ou ta font perso */
font-weight: 700;
font-size: 1.2rem;
letter-spacing: -0.02em;
@@ -1,4 +1,4 @@
import {
import React, {
useLayoutEffect,
useRef,
useState,
@@ -10,22 +10,34 @@ import {
import { Link, useNavigate, useLocation } from "react-router-dom";
import { gsap } from "gsap";
import "./CardNav.css";
import { mainMenuItems, projectMenuItems } from "./data/DataMenuItem";
const InfiniteMenu = lazy(() => import("./InfiniteMenu"));
import { mainMenuItems, projectMenuItems, MenuItem } from "./data/DataMenuItem";
const InfiniteMenu = lazy(
() => import("./InfiniteMenu"),
) as React.ComponentType<any>;
const Lanyard = lazy(() => import("./Lanyard"));
const CardNav = ({
interface CardNavProps {
logo?: string;
logoAlt?: string;
className?: string;
ease?: string;
}
const CardNav: React.FC<CardNavProps> = ({
logo = "/images/logo.webp",
logoAlt = "Esiah Logo",
className = "",
ease = "power3.out",
}) => {
const [isHamburgerOpen, setIsHamburgerOpen] = useState(false);
const [isExpanded, setIsExpanded] = useState(false);
const [showLanyard, setShowLanyard] = useState(false);
const navRef = useRef(null);
const tlRef = useRef(null);
const [isHamburgerOpen, setIsHamburgerOpen] = useState<boolean>(false);
const [isExpanded, setIsExpanded] = useState<boolean>(false);
const [showLanyard, setShowLanyard] = useState<boolean>(false);
const navRef = useRef<HTMLElement>(null);
const tlRef = useRef<gsap.core.Timeline | null>(null);
const location = useLocation();
const navigate = useNavigate();
@@ -49,7 +61,7 @@ const CardNav = ({
}
};
const handleCardClick = (link) => {
const handleCardClick = (link: string) => {
if (!link) return;
const cleanLink = link.replace("_blank", "").trim();
if (link.includes("_blank") || cleanLink.startsWith("http")) {
@@ -68,7 +80,7 @@ const CardNav = ({
}
};
const menuItems = useMemo(() => {
const menuItems: MenuItem[] = useMemo(() => {
if (location.pathname.startsWith("/projects")) {
return projectMenuItems;
}
@@ -93,7 +105,9 @@ const CardNav = ({
useLayoutEffect(() => {
const tl = createTimeline();
tlRef.current = tl;
return () => tl?.kill();
return () => {
tl?.kill();
};
}, [createTimeline]);
return (
@@ -130,7 +144,7 @@ const CardNav = ({
alt={logoAlt}
className="nav-logo-img"
onError={(e) => {
e.target.style.display = "none";
(e.target as HTMLImageElement).style.display = "none";
}}
/>
</Link>
@@ -146,7 +160,7 @@ const CardNav = ({
>
<Suspense fallback={null}>
<InfiniteMenu
items={menuItems}
items={menuItems as any}
scale={0.8}
onClose={closeMenuIfOpen}
onItemClick={handleCardClick}
+28 -18
View File
@@ -1,5 +1,3 @@
/* src/components/InfiniteMenu.css */
#infinite-grid-menu-canvas {
cursor: grab;
width: 100%;
@@ -14,13 +12,13 @@
cursor: grabbing;
}
/* Conteneur pour centrer les éléments par dessus le canvas */
.infinite-menu-overlay {
position: absolute;
inset: 0;
pointer-events: none;
z-index: 2;
}
.infinite-menu-overlay::before {
content: "";
position: absolute;
@@ -38,25 +36,21 @@
.face-title.inactive ~ ::before {
opacity: 0;
}
/* --- BOUTON D'ACTION --- */
.action-button {
position: absolute;
left: 50%;
bottom: 8%; /* Un peu plus bas pour laisser respirer le texte */
bottom: 8%;
z-index: 10;
/* Dimensions de la bannière */
padding: 12px 32px;
display: flex;
align-items: center;
gap: 12px;
/* Style visuel */
background: var(--clr-accent-600);
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 40px; /* Forme pilule */
border-radius: 40px;
cursor: pointer;
/* Animation d'entrée */
transform: translateX(-50%) translateY(20px);
opacity: 0;
pointer-events: none;
@@ -69,10 +63,8 @@
pointer-events: auto;
}
/* Texte à l'intérieur */
.action-button-text {
color: #fff;
font-weight: 600;
font-size: 0.95rem;
text-transform: uppercase;
@@ -85,7 +77,6 @@
transition: transform 0.3s ease;
}
/* --- EFFET HOVER --- */
.action-button:hover {
background: #fff;
box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
@@ -106,9 +97,10 @@
pointer-events: none;
}
/* --- TITRE --- */
.face-title {
position: absolute;
top: 40%;
top: 36%;
left: 50%;
transform: translate(-50%, -50%);
@@ -117,7 +109,10 @@
color: #fff;
text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
text-align: center;
width: 100%;
width: 90%;
text-wrap: balance;
line-height: 1.1;
opacity: 0;
pointer-events: none;
@@ -130,15 +125,25 @@
transition: 0.5s ease;
}
/* --- DESCRIPTION --- */
.face-description {
position: absolute;
top: 55%;
top: 58%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 1rem;
color: #ccc;
text-align: center;
max-width: 80%;
max-width: 85%;
line-height: 1.4;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
opacity: 0;
pointer-events: none;
@@ -151,11 +156,16 @@
transition: 0.5s ease;
}
/* --- RESPONSIVE MOBILE --- */
@media (max-width: 768px) {
.face-title {
font-size: 2rem;
top: 34%;
}
.face-description {
font-size: 0.9rem;
top: 56%;
-webkit-line-clamp: 3;
line-clamp: 3;
}
}
+1 -1
View File
@@ -15,7 +15,7 @@ export const gameDevItems = [
link: "/projects/echoes-of-the-last-stop",
title: "Echoes of the Last Stop",
description:
"Story-driven thriller game with branching narratives in collaboration with my partner made with Unity & Aseprite.",
"Story-driven thriller game in collaboration with my partner made with Unity & Aseprite.",
},
{
id: "3",