fix: apply designer agent improvements to src/App.tsx

This commit is contained in:
cupadev-admin 2026-03-09 07:11:12 +00:00
parent 535cedd30b
commit f5fdc9a370
1 changed files with 52 additions and 12 deletions

View File

@ -7,9 +7,13 @@ import Gallery from './components/Gallery';
import Events from './components/Events';
import Contact from './components/Contact';
import Footer from './components/Footer';
import Musee from './components/Musee';
type Page = 'home' | 'musee';
function App() {
const [scrolled, setScrolled] = useState(false);
const [currentPage, setCurrentPage] = useState<Page>('home');
useEffect(() => {
const handleScroll = () => setScrolled(window.scrollY > 60);
@ -17,19 +21,55 @@ function App() {
return () => window.removeEventListener('scroll', handleScroll);
}, []);
// Simple hash-based routing
useEffect(() => {
const checkRoute = () => {
if (window.location.hash === '#musee-page') {
setCurrentPage('musee');
window.scrollTo(0, 0);
} else {
setCurrentPage('home');
}
};
checkRoute();
window.addEventListener('hashchange', checkRoute);
return () => window.removeEventListener('hashchange', checkRoute);
}, []);
const navigateTo = (page: Page) => {
setCurrentPage(page);
window.scrollTo({ top: 0, behavior: 'smooth' });
if (page === 'musee') {
window.history.pushState(null, '', '#musee-page');
} else {
window.history.pushState(null, '', '/');
}
};
return (
<>
<a href="#main-content" className="skip-link">
Aller au contenu principal
</a>
<div className="min-h-screen">
<Header scrolled={scrolled} />
<main>
<Header scrolled={scrolled} currentPage={currentPage} navigateTo={navigateTo} />
<main id="main-content" tabIndex={-1}>
{currentPage === 'musee' ? (
<Musee navigateTo={navigateTo} />
) : (
<>
<Hero />
<About />
<History />
<Gallery />
<Gallery navigateTo={navigateTo} />
<Events />
<Contact />
</>
)}
</main>
<Footer />
<Footer navigateTo={navigateTo} />
</div>
</>
);
}