diff --git a/components/NavBar.js b/components/NavBar.js index ea40a0da..a459e0f8 100644 --- a/components/NavBar.js +++ b/components/NavBar.js @@ -58,6 +58,75 @@ const NavItem = ({ label, href, ...props }) => { ) } +const SubNavItem = ({ label, href, ...props }) => { + const { pathname } = useRouter() + const [isActive, setIsActive] = useState(false) + + useEffect(() => { + setIsActive(pathname === href) + }, [pathname, href]) + + return ( + + {label} + + ) +} + +const SubMenu = () => { + const { pathname } = useRouter() + const [showSubMenu, setshowSubMenu] = useState(false) + + const menuItem = [ + { + label: , + href: '/chart/circumvention', + umami: 'navigation-circumvention', + }, + { + label: , + href: '/domains', + umami: 'navigation-domains"', + }, + { + label: , + href: '/networks', + umami: 'navigation-networks', + }, + ] + + useEffect(() => { + setshowSubMenu(menuItem.map((i) => i.href).includes(pathname)) + }, [pathname]) + + return ( + <> + {showSubMenu && ( +
+
+
+ +
+
+
+ )} + + ) +} + const languages = process.env.LOCALES export const NavBar = ({ color }) => { @@ -84,93 +153,85 @@ export const NavBar = ({ color }) => { useEffect(() => { setShowMenu(false) }, [pathname]) - return ( -
-
-
-
- - - -
-
- setShowMenu(!showMenu)} - /> -
- {showMenu && ( -
- setShowMenu(!showMenu)} - /> -
- )} +
+
+
+
+
+ + + +
+
+ setShowMenu(!showMenu)} + />
a]:border-black [&>a]:hover:border-black [&>*]:opacity-100 [&>*]:text-black [&>*]:hover:text-black'}`} + className={`z-[9999] lg:block ${showMenu ? 'block overflow-y-scroll max-h-full p-8 text-base fixed top-0 right-0 bg-gray-50' : 'hidden'}`} > - } - href="/search" - data-umami-event="navigation-search" - /> - } - href="/chart/mat" - data-umami-event="navigation-mat" - /> - } - href="/chart/circumvention" - data-umami-event="navigation-circumvention" - /> - } - href="/countries" - data-umami-event="navigation-countries" - /> - } - href="/networks" - data-umami-event="navigation-networks" - /> - } - href="/domains" - data-umami-event="navigation-domains" - /> - } - href="/findings" - data-umami-event="navigation-findings" - /> - {user?.logged_in && ( - - - + {showMenu && ( +
+ setShowMenu(!showMenu)} + /> +
)} - - {languages.map((c) => ( - - ))} - +
a]:border-black [&>a]:hover:border-black [&>*]:opacity-100 [&>*]:text-black [&>*]:hover:text-black'}`} + > + } + href="/findings" + data-umami-event="navigation-findings" + /> + } + href="/chart/circumvention" + data-umami-event="navigation-censorship" + /> + } + href="/countries" + data-umami-event="navigation-countries" + /> + } + href="/chart/mat" + data-umami-event="navigation-mat" + /> + } + href="/search" + data-umami-event="navigation-search" + /> + {user?.logged_in && ( + + + + )} + + {languages.map((c) => ( + + ))} + +
+
) } diff --git a/components/SharedStyledComponents.js b/components/SharedStyledComponents.js index 289fc97b..ef9f2e75 100644 --- a/components/SharedStyledComponents.js +++ b/components/SharedStyledComponents.js @@ -9,16 +9,16 @@ export const StyledStickyNavBar = ({ ...props }) => (
) -export const StyledStickySubMenu = ({ ...props }) => ( +export const StyledStickySubMenu = ({ topClass, ...props }) => (
) -export const StickySubMenu = ({ title, children }) => { +export const StickySubMenu = ({ title, children, topClass }) => { return ( - +

{title}

{children} diff --git a/pages/domains.js b/pages/domains.js index a3f680b6..14ebd757 100644 --- a/pages/domains.js +++ b/pages/domains.js @@ -112,6 +112,7 @@ const Domains = () => {
{intl.formatMessage({ id: 'Domains.Title' })}{' '} diff --git a/pages/networks.js b/pages/networks.js index 3fa80fc6..4fe0d1ac 100644 --- a/pages/networks.js +++ b/pages/networks.js @@ -78,6 +78,7 @@ const Networks = () => {
{intl.formatMessage({ id: 'Networks.Title' })}{' '} diff --git a/public/static/lang/en.json b/public/static/lang/en.json index 98ae9c2c..b1c88cbf 100644 --- a/public/static/lang/en.json +++ b/public/static/lang/en.json @@ -274,9 +274,11 @@ "Measurement.Feedback.Login.Description": "We will send a link to your email. We do not store emails.", "Measurement.Feedback.ExistingFeedback": "Your previous feedback", "Navbar.Search": "Search", + "Navbar.Censorship": "Censorship", "Navbar.Countries": "Countries", "Navbar.Charts.Circumvention": "Circumvention Charts", "Navbar.Charts.MAT": "MAT Charts", + "Navbar.Charts": "Charts", "Navbar.Domains": "Domains", "Navbar.Networks": "Networks", "Navbar.Findings": "Findings",