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

made the main page static and enabled scrolling in the filters component #5932

Closed
Closed
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions frontend/src/assets/styles/_extra.scss
Original file line number Diff line number Diff line change
Expand Up @@ -616,3 +616,7 @@ a[href="https://www.mapbox.com/map-feedback/"]
.link:focus {
outline: revert;
}

.scrollable-container::-webkit-scrollbar {
width: 0;
}
HelNershingThapa marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion frontend/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const Header = () => {
) : null;

return (
<header className="w-100 bb b--grey-light">
<header id="top-header" className="w-100 bb b--grey-light">
<UpdateDialog />
{checkUserEmail()}
{showOrgBar && (
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/projects/projectNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const ProjectNav = (props) => {
// onSelectedItemChange={(changes) => console.log(changes)}
return (
/* mb1 mb2-ns (removed for map, but now small gap for more-filters) */
<header className="bt bb b--tan w-100 ">
<header id="explore-nav" className="bt bb b--tan w-100 ">
<div className="mt2 mb1 ph3 dib lh-copy w-100 cf">
<div className="w-80-l w-90-m w-100 fl dib">
<div className="dib">
Expand Down
42 changes: 39 additions & 3 deletions frontend/src/views/project.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Suspense, useEffect } from 'react';
import React, { Suspense, useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import ReactPlaceholder from 'react-placeholder';
import { Outlet, useLocation, useNavigate, useParams } from 'react-router-dom';
Expand Down Expand Up @@ -151,15 +151,51 @@ export const ProjectsPageIndex = (props) => {
export const MoreFilters = () => {
const navigate = useNavigate();
const [fullProjectsQuery] = useExploreProjectsQueryParams();
const [componentHeight, setComponentHeight] = useState(`${window.innerHeight}px`);

useEffect(() => {
// Disable scrolling outside the component when it appears
document.body.style.overflow = 'hidden';
document.documentElement.style.overflow = 'hidden';

return () => {
// Restore scrolling when the component is closed
document.body.style.overflow = 'auto';
document.documentElement.style.overflow = 'auto';
};
}, []);

useEffect(() => {
const contentHeight =
document.getElementById('explore-nav').offsetHeight +
document.getElementById('top-header').offsetHeight;

const handleResize = () => {
setComponentHeight(window.innerHeight - contentHeight);
};

handleResize();

window.addEventListener('resize', handleResize);

return () => {
window.removeEventListener('resize', handleResize);
};
});
HelNershingThapa marked this conversation as resolved.
Show resolved Hide resolved

const currentUrl = `/explore${
stringify(fullProjectsQuery) ? ['?', stringify(fullProjectsQuery)].join('') : ''
}`;

return (
<>
<div className="absolute left-0 z-4 mt1 w-40-l w-100 h-100 bg-white h4 ph1 ph5-l">
<MoreFiltersForm currentUrl={currentUrl} />
<div
className="absolute left-0 z-4 mt1 w-40-l w-100 bg-white h4 ph1 ph5-l"
style={{ height: `${componentHeight}px` }}
>
<div className="scrollable-container h-100 overflow-auto">
<MoreFiltersForm currentUrl={currentUrl} />
</div>
</div>
<div
onClick={() => navigate(currentUrl)}
Expand Down