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

Add dropdown nav for about pages #4290

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
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
22 changes: 22 additions & 0 deletions site/SiteAbout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as React from "react"

export const ABOUT_LINKS = [
{ title: "About Us", href: "/about" },
{ title: "Organization", href: "/organization" },
{ title: "Funding", href: "/funding" },
{ title: "Team", href: "/team" },
{ title: "Jobs", href: "/jobs" },
{ title: "FAQs", href: "/faqs" },
]

export function SiteAbout() {
return (
<ul>
{ABOUT_LINKS.map(({ title, href }) => (
<li key={href}>
<a href={href}>{title}</a>
</li>
))}
</ul>
)
}
16 changes: 14 additions & 2 deletions site/SiteMobileMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { CategoryWithEntries } from "@ourworldindata/utils"
import classnames from "classnames"
import { SiteNavigationToggle } from "./SiteNavigationToggle.js"
import { Menu } from "./SiteNavigation.js"
import { SiteAbout } from "./SiteAbout.js"
import { SiteResources } from "./SiteResources.js"
import { SiteMobileCategory } from "./SiteMobileCategory.js"

Expand Down Expand Up @@ -68,9 +69,20 @@ export const SiteMobileMenu = ({
</SiteNavigationToggle>
</li>
<li>
<a href="/about" className="section__header">
<SiteNavigationToggle
ariaLabel="Toggle about menu"
isActive={menu === Menu.About}
onToggle={() =>
toggleMenu(
menu === Menu.About ? Menu.Topics : Menu.About
)
}
dropdown={<SiteAbout />}
withCaret={true}
className="SiteNavigationToggle--lvl1"
>
About
</a>
</SiteNavigationToggle>
</li>
<li>
<a href="/donate" className="donate">
Expand Down
13 changes: 11 additions & 2 deletions site/SiteNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
OwidGdocType,
getOwidGdocFromJSON,
} from "@ourworldindata/utils"
import { SiteAbout } from "./SiteAbout.js"
import { SiteResources } from "./SiteResources.js"
import { SiteSearchNavigation } from "./SiteSearchNavigation.js"
import { SiteMobileMenu } from "./SiteMobileMenu.js"
Expand Down Expand Up @@ -174,8 +175,16 @@ export const SiteNavigation = ({
Resources
</SiteNavigationToggle>
</li>
<li>
<a href="/about">About</a>
<li className="with-relative-dropdown">
<SiteNavigationToggle
ariaLabel="Toggle about menu"
isActive={menu === Menu.About}
onToggle={() => toggleMenu(Menu.About)}
dropdown={<SiteAbout />}
withCaret={true}
>
About
</SiteNavigationToggle>
</li>
</ul>
</nav>
Expand Down
27 changes: 10 additions & 17 deletions site/gdocs/pages/AboutPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@ import { isEmpty } from "lodash"
import * as React from "react"

import { OwidGdocAboutInterface } from "@ourworldindata/types"
import { ABOUT_LINKS } from "../../SiteAbout.js"
import { ArticleBlocks } from "../components/ArticleBlocks.js"
import Footnotes from "../components/Footnotes.js"

const NAV_LINKS = [
{ title: "About Us", href: "/about" },
{ title: "Organization", href: "/organization" },
{ title: "Funding", href: "/funding" },
{ title: "Team", href: "/team" },
{ title: "Jobs", href: "/jobs" },
{ title: "FAQs", href: "/faqs" },
]

export default function AboutPage({ content, slug }: OwidGdocAboutInterface) {
return (
<main className="about-page centered-article-container grid grid-cols-12-full-width">
Expand All @@ -39,21 +31,22 @@ function AboutNav({ slug }: { slug: string }) {
return (
<nav className="about-nav grid grid-cols-12-full-width col-start-1 col-end-limit">
<ul className="about-nav-list col-start-2 col-end-14 col-sm-start-1">
{NAV_LINKS.map(({ title, href }) => (
<li key={href}>
<h2>
{ABOUT_LINKS.map(({ title, href }) => {
const isActive = href === `/${slug}`
return (
<li key={href}>
<a
className={cx("about-nav-link", {
"about-nav-link--is-active":
href === `/${slug}`,
"about-nav-link--is-active": isActive,
})}
href={href}
aria-current={isActive ? "page" : undefined}
>
{title}
</a>
</h2>
</li>
))}
</li>
)
})}
</ul>
</nav>
)
Expand Down
Loading