diff --git a/server/sanity.ts b/server/sanity.ts index c1a1dd3..71d1816 100644 --- a/server/sanity.ts +++ b/server/sanity.ts @@ -106,6 +106,7 @@ const navQuery = ` } } } + inTwoColumns }, rightSide { search { diff --git a/src/components/DropdownMenu/DropdownMenuItem.tsx b/src/components/DropdownMenu/DropdownMenuItem.tsx index 349bd32..c4d8563 100644 --- a/src/components/DropdownMenu/DropdownMenuItem.tsx +++ b/src/components/DropdownMenu/DropdownMenuItem.tsx @@ -3,7 +3,7 @@ import { clsx } from "clsx"; import Link from "../Link"; import styles from "./DropdownMenuItem.module.css"; - +import cn from "classnames"; export interface MenuItemProps { itemType: string | "normal" | "image"; icon?: string | null; @@ -59,7 +59,7 @@ const DropdownMenuItem = ({ alt="" /> -
+

{customImage?.itemTitle}

{customImage?.imageDate && (

{customImage?.imageDate}

diff --git a/src/components/DropdownMenu/DropdownSection.module.css b/src/components/DropdownMenu/DropdownSection.module.css index 64b1376..ab4a150 100644 --- a/src/components/DropdownMenu/DropdownSection.module.css +++ b/src/components/DropdownMenu/DropdownSection.module.css @@ -61,3 +61,12 @@ } } } + +.inTwoColumns { + display: grid; + grid-template-columns: 1fr; + column-gap: 4px; + @media (--nav) { + grid-template-columns: 1fr 1fr; + } +} diff --git a/src/components/DropdownMenu/DropdownSection.tsx b/src/components/DropdownMenu/DropdownSection.tsx index d16bbff..8d89e8f 100644 --- a/src/components/DropdownMenu/DropdownSection.tsx +++ b/src/components/DropdownMenu/DropdownSection.tsx @@ -1,6 +1,5 @@ -import { clsx } from "clsx"; - import styles from "./DropdownSection.module.css"; +import cn from "classnames"; export interface DropdownMenuProps { title?: string; @@ -11,6 +10,7 @@ export interface DropdownMenuProps { isImageLink?: boolean; childLength?: number; isFirst: boolean; + inTwoColumns?: boolean; } const DropdownSection = ({ @@ -23,12 +23,13 @@ const DropdownSection = ({ childLength = 3, isFirst, className, + inTwoColumns = false, ...props }: DropdownMenuProps & React.HTMLAttributes) => { const textExists = title || subtitle ? true : false; return (
{subtitle}

}
)} -
+
{children}
diff --git a/src/components/DropdownMenu/DropdownSubMenu.tsx b/src/components/DropdownMenu/DropdownSubMenu.tsx index cdf305a..5af6781 100644 --- a/src/components/DropdownMenu/DropdownSubMenu.tsx +++ b/src/components/DropdownMenu/DropdownSubMenu.tsx @@ -1,11 +1,11 @@ import { useState } from "react"; -import { clsx } from "clsx"; import type { NavigationItem } from "../../../server/sanity-types"; import Icon from "../Icon"; import Link from "../Link"; import DropdownMenuItem from "./DropdownMenuItem"; +import cn from "classnames"; import DropdownSection from "./DropdownSection"; import styles from "./DropdownSubMenu.module.css"; @@ -33,11 +33,19 @@ const DropdownSubMenu = ({ items }: DropdownMenuProps) => { return (
setActiveTab(index)} + tabIndex={0} + onKeyDown={(e) => { + if (e.key === "Enter" || e.key === " ") { + e.preventDefault(); + setActiveTab(index); + } + }} + aria-expanded={activeTab === index} > {submenuTitle} @@ -51,36 +59,47 @@ const DropdownSubMenu = ({ items }: DropdownMenuProps) => { .map(({ submenuSections, submenuTitle }, i) => (
- {submenuSections?.map((section, index) => ( - itemType === "normal" - ) && styles.normal, - index === submenuSections.length - 1 && styles.last - )} - > - {section.sectionItems.map((sectionItemProps, i) => ( - - ))} - - ))} + {submenuSections?.map((section, index) => { + const middleIndex = Math.ceil(section.sectionItems.length / 2); + const items = section.inTwoColumns + ? [ + section.sectionItems.slice(0, middleIndex), + section.sectionItems.slice(middleIndex), + ] + : [section.sectionItems]; + return ( + itemType === "normal" + ) && styles.normal, + index === submenuSections.length - 1 && styles.last + )} + > + {items.map((item, j) => ( +
+ {item.map((sectionItemProps, i) => ( + + ))} +
+ ))} +
+ ); + })}
))}