Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed scroll to top developers page #2140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 26 additions & 22 deletions src/pages/DeveloperLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,44 @@ import style from "../style/index.js";
import PageHeader from "../layout/PageHeader.jsx";
import { Outlet, useLocation } from "react-router-dom";
import { Helmet } from "react-helmet";
import { useEffect } from "react";

export default function DeveloperLayout() {
const { pathname } = useLocation();

// Scroll to top on pathname change
useEffect(() => {
window.scrollTo(0, 0);
}, [pathname]);

const renderMainContent = () => (
<>
<Header />
<PageHeader
title="Developer Tools"
backgroundColor={style.colors.BLUE_98}
>
<p style={{ margin: 0 }}>
Welcome to the Developer Tools page for PolicyEngine. This hub is
designed to enhance your experience with our open-source projects by
providing quick access to essential resources.
</p>
</PageHeader>
<Outlet />
<Footer />
</>
);

if (pathname.length > 20) {
return (
<main>
<Outlet />
</main>
);
return <main><Outlet /></main>;
}

return (
<main>
<Helmet>
<title>Developer Tools | PolicyEngine</title>
</Helmet>
<div>
<Header />

<PageHeader
title="Developer Tools"
backgroundColor={style.colors.BLUE_98}
>
<p style={{ margin: 0 }}>
Welcome to the Developer Tools page for PolicyEngine. This hub is
designed to enhance your experience with our open-source projects by
providing quick access to essential resources.
</p>
</PageHeader>

<Outlet />
<Footer />
</div>
{renderMainContent()}
</main>
);
}
Loading