diff --git a/src/client/components/Navigation/NavAssessment/NavAssessment.scss b/src/client/components/Navigation/NavAssessment/NavAssessment.scss new file mode 100644 index 0000000000..56aae9d6ff --- /dev/null +++ b/src/client/components/Navigation/NavAssessment/NavAssessment.scss @@ -0,0 +1,8 @@ +@import 'src/client/style/partials'; + +.nav-assessment { + overflow-y: auto; + padding: $spacing-xxs 0; + position: sticky; + top: 50px; +} diff --git a/src/client/components/Navigation/NavAssessment/NavAssessment.tsx b/src/client/components/Navigation/NavAssessment/NavAssessment.tsx index fcd65f2077..82f2f4adfc 100644 --- a/src/client/components/Navigation/NavAssessment/NavAssessment.tsx +++ b/src/client/components/Navigation/NavAssessment/NavAssessment.tsx @@ -1,20 +1,24 @@ +import './NavAssessment.scss' import React, { useState } from 'react' import { Objects } from 'utils/objects' import { useSections } from 'client/store/metadata' +import Header from 'client/components/Navigation/NavAssessment/Header' +import NavigationSection from 'client/components/Navigation/NavAssessment/Section' -import Header from './Header' -import NavigationSection from './Section' +import { useMaxHeight } from './hooks/useMaxHeight' const NavAssessment: React.FC = () => { const sections = useSections() - const [showSections, setShowSections] = useState(false) + + const maxHeight = useMaxHeight() + const [showSections, setShowSections] = useState(false) if (Objects.isEmpty(sections)) return null return ( -
+
{sections.map((section) => ( diff --git a/src/client/components/Navigation/NavAssessment/hooks/useMaxHeight.ts b/src/client/components/Navigation/NavAssessment/hooks/useMaxHeight.ts new file mode 100644 index 0000000000..93a064e764 --- /dev/null +++ b/src/client/components/Navigation/NavAssessment/hooks/useMaxHeight.ts @@ -0,0 +1,35 @@ +import { useEffect, useRef, useState } from 'react' + +// document height - toolbar +const baseHeight = `100dvh - 50px` + +export const useMaxHeight = (): string => { + const [maxHeight, setMaxHeight] = useState(`calc(${baseHeight})`) + const heightsRef = useRef>({}) + + useEffect(() => { + const observer = new IntersectionObserver( + (entries) => { + entries.forEach((entry) => { + heightsRef.current[entry.target.tagName] = entry.intersectionRect.height + }) + + const heightsCalc = Object.values(heightsRef.current) + .map((v) => `${v}px`) + .join(' - ') + + setMaxHeight(`calc(100dvh - 50px - ${heightsCalc})`) + }, + { threshold: [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1] } + ) + + observer.observe(document.getElementsByTagName('header')[0]) + observer.observe(document.getElementsByTagName('footer')[0]) + + return () => { + observer.disconnect() + } + }, []) + + return maxHeight +} diff --git a/src/client/components/Navigation/Navigation.scss b/src/client/components/Navigation/Navigation.scss index 2147f9acfc..67f7df26d3 100644 --- a/src/client/components/Navigation/Navigation.scss +++ b/src/client/components/Navigation/Navigation.scss @@ -8,10 +8,7 @@ .nav { @extend .nav-base; grid-area: navigation; - overflow-x: hidden; - overflow-y: auto; height: 100%; - padding: 8px 0; .nav__bulk-download { margin-left: 16px; diff --git a/src/client/components/PageLayout/Header/FraHeader/FraHeader.tsx b/src/client/components/PageLayout/Header/FraHeader/FraHeader.tsx index 887f196f8a..9668a92757 100644 --- a/src/client/components/PageLayout/Header/FraHeader/FraHeader.tsx +++ b/src/client/components/PageLayout/Header/FraHeader/FraHeader.tsx @@ -13,7 +13,7 @@ const FraHeader: React.FC = () => { const cycle = useCycle() return ( -
+
FAO
@@ -29,7 +29,7 @@ const FraHeader: React.FC = () => {
-
+
) } diff --git a/src/client/components/PageLayout/Header/PanEuropeanHeader/PanEuropeanHeader.tsx b/src/client/components/PageLayout/Header/PanEuropeanHeader/PanEuropeanHeader.tsx index d3583d70fb..7c3f8ac294 100644 --- a/src/client/components/PageLayout/Header/PanEuropeanHeader/PanEuropeanHeader.tsx +++ b/src/client/components/PageLayout/Header/PanEuropeanHeader/PanEuropeanHeader.tsx @@ -12,7 +12,7 @@ const PanEuropeanHeader: React.FC = () => { const cycle = useCycle() return ( -
+
FAO
@@ -24,7 +24,7 @@ const PanEuropeanHeader: React.FC = () => {
-
+
) }