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 Events from './components/Events';
|
||||||
import Contact from './components/Contact';
|
import Contact from './components/Contact';
|
||||||
import Footer from './components/Footer';
|
import Footer from './components/Footer';
|
||||||
|
import Musee from './components/Musee';
|
||||||
|
|
||||||
|
type Page = 'home' | 'musee';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [scrolled, setScrolled] = useState(false);
|
const [scrolled, setScrolled] = useState(false);
|
||||||
|
const [currentPage, setCurrentPage] = useState<Page>('home');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleScroll = () => setScrolled(window.scrollY > 60);
|
const handleScroll = () => setScrolled(window.scrollY > 60);
|
||||||
|
|
@ -17,19 +21,55 @@ function App() {
|
||||||
return () => window.removeEventListener('scroll', handleScroll);
|
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 (
|
return (
|
||||||
<div className="min-h-screen">
|
<>
|
||||||
<Header scrolled={scrolled} />
|
<a href="#main-content" className="skip-link">
|
||||||
<main>
|
Aller au contenu principal
|
||||||
<Hero />
|
</a>
|
||||||
<About />
|
<div className="min-h-screen">
|
||||||
<History />
|
<Header scrolled={scrolled} currentPage={currentPage} navigateTo={navigateTo} />
|
||||||
<Gallery />
|
<main id="main-content" tabIndex={-1}>
|
||||||
<Events />
|
{currentPage === 'musee' ? (
|
||||||
<Contact />
|
<Musee navigateTo={navigateTo} />
|
||||||
</main>
|
) : (
|
||||||
<Footer />
|
<>
|
||||||
</div>
|
<Hero />
|
||||||
|
<About />
|
||||||
|
<History />
|
||||||
|
<Gallery navigateTo={navigateTo} />
|
||||||
|
<Events />
|
||||||
|
<Contact />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</main>
|
||||||
|
<Footer navigateTo={navigateTo} />
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue