mirror of
https://github.com/Ladebeze66/devsite.git
synced 2025-12-13 12:46:49 +01:00
firt
This commit is contained in:
parent
c356a67055
commit
9cd6467cd9
@ -1,36 +1,38 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import React, { useEffect, useState, useRef } from "react";
|
||||
import Footer from "./components/Footer";
|
||||
import "./assets/main.css";
|
||||
import NavLink from "./components/NavLink";
|
||||
|
||||
export default function RootLayout({ children }) {
|
||||
// États pour gérer la largeur et la hauteur du conteneur principal
|
||||
const [numElements, setNumElements] = useState(0);
|
||||
// Référence pour observer la taille du conteneur
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const [containerWidth, setContainerWidth] = useState("max-w-4xl");
|
||||
const [containerHeight, setContainerHeight] = useState("min-h-[50vh]");
|
||||
|
||||
useEffect(() => {
|
||||
// Compter le nombre d'éléments enfants
|
||||
const elementsCount = React.Children.count(children);
|
||||
setNumElements(elementsCount);
|
||||
const observer = new ResizeObserver((entries) => {
|
||||
for (let entry of entries) {
|
||||
const width = entry.contentRect.width;
|
||||
|
||||
if (width > 1400) {
|
||||
setContainerWidth("max-w-full");
|
||||
} else if (width > 1200) {
|
||||
setContainerWidth("max-w-6xl");
|
||||
} else if (width > 1000) {
|
||||
setContainerWidth("max-w-5xl");
|
||||
} else {
|
||||
setContainerWidth("max-w-4xl");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Ajuster la largeur et la hauteur en fonction du nombre d'éléments
|
||||
if (elementsCount > 10) {
|
||||
setContainerWidth("max-w-full");
|
||||
setContainerHeight("min-h-[90vh]");
|
||||
} else if (elementsCount > 5) {
|
||||
setContainerWidth("max-w-6xl");
|
||||
setContainerHeight("min-h-[80vh]");
|
||||
} else if (elementsCount > 3) {
|
||||
setContainerWidth("max-w-5xl");
|
||||
setContainerHeight("min-h-[70vh]");
|
||||
} else {
|
||||
setContainerWidth("max-w-4xl");
|
||||
setContainerHeight("min-h-[60vh]");
|
||||
if (containerRef.current) {
|
||||
observer.observe(containerRef.current);
|
||||
}
|
||||
}, [children]);
|
||||
return () => observer.disconnect();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<html lang="fr">
|
||||
@ -42,36 +44,36 @@ export default function RootLayout({ children }) {
|
||||
<div className="circle-one blur-3xl w-64 h-64 rounded-full bg-rose-400/60 top-0 right-28 absolute"></div>
|
||||
<div className="circle-two blur-3xl w-64 h-64 rounded-full bg-indigo-400/60 bottom-0 left-28 absolute"></div>
|
||||
</div>
|
||||
|
||||
{/* En-tête avec navigation */}
|
||||
<header className="z-10 bg-white/50 backdrop-blur rounded-lg border-2 border-gray-500">
|
||||
<div className="max-w-4xl mx-auto flex items-center justify-between p-4">
|
||||
<h2 className="text-2xl font-bold">Portofolio Gras-Calvet Fernand</h2>
|
||||
<nav>
|
||||
<ul className="flex gap-x-7 text-black-500 font-bold">
|
||||
<li>
|
||||
<NavLink text="Accueil" path="/" />
|
||||
</li>
|
||||
<li>
|
||||
<NavLink text="Portfolio" path="/portfolio" />
|
||||
</li>
|
||||
<li>
|
||||
<NavLink text="Compétences" path="/competences" />
|
||||
</li>
|
||||
<li>
|
||||
<NavLink text="Contact" path="/contact" />
|
||||
</li>
|
||||
<li><NavLink text="Accueil" path="/" /></li>
|
||||
<li><NavLink text="Portfolio" path="/portfolio" /></li>
|
||||
<li><NavLink text="Compétences" path="/competences" /></li>
|
||||
<li><NavLink text="Contact" path="/contact" /></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
{/* Conteneur principal pour le contenu */}
|
||||
<main className={`backdrop-blur z-10 ${containerWidth} ${containerHeight} mx-auto bg-white/20 rounded-xl py-7 px-8 m-6 overflow-hidden`}>
|
||||
{children}
|
||||
</main>
|
||||
|
||||
{/* Conteneur principal avec ajustement dynamique et scroll horizontal si nécessaire */}
|
||||
<div className="overflow-x-auto">
|
||||
<main
|
||||
ref={containerRef}
|
||||
className={`backdrop-blur z-10 ${containerWidth} ${containerHeight} mx-auto bg-white/20 rounded-xl py-7 px-8 m-6`}
|
||||
>
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
|
||||
{/* Pied de page */}
|
||||
<Footer />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user