fix: apply designer agent improvements to src/App.tsx
This commit is contained in:
parent
535cedd30b
commit
f5fdc9a370
64
src/App.tsx
64
src/App.tsx
|
|
@ -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 (
|
||||
<div className="min-h-screen">
|
||||
<Header scrolled={scrolled} />
|
||||
<main>
|
||||
<Hero />
|
||||
<About />
|
||||
<History />
|
||||
<Gallery />
|
||||
<Events />
|
||||
<Contact />
|
||||
</main>
|
||||
<Footer />
|
||||
</div>
|
||||
<>
|
||||
<a href="#main-content" className="skip-link">
|
||||
Aller au contenu principal
|
||||
</a>
|
||||
<div className="min-h-screen">
|
||||
<Header scrolled={scrolled} currentPage={currentPage} navigateTo={navigateTo} />
|
||||
<main id="main-content" tabIndex={-1}>
|
||||
{currentPage === 'musee' ? (
|
||||
<Musee navigateTo={navigateTo} />
|
||||
) : (
|
||||
<>
|
||||
<Hero />
|
||||
<About />
|
||||
<History />
|
||||
<Gallery navigateTo={navigateTo} />
|
||||
<Events />
|
||||
<Contact />
|
||||
</>
|
||||
)}
|
||||
</main>
|
||||
<Footer navigateTo={navigateTo} />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue