diff --git a/components/OrganizedContent.tsx b/components/OrganizedContent.tsx index dfda7a3d..4f5704a7 100644 --- a/components/OrganizedContent.tsx +++ b/components/OrganizedContent.tsx @@ -12,6 +12,7 @@ export interface LinkProps { className?: string; id: string; children: ReactNode; + setMobileNavOpen?: React.Dispatch>; } type Link = ComponentType; @@ -71,6 +72,7 @@ export function OrganizedContent(props: Props) { currentIndex={currentIndex} link={props.link} pageTitle={props.pageTitle} + setMobileNavOpen={setMobileNavOpen} /> @@ -143,9 +145,16 @@ interface NavProps { currentIndex: number; link: Link; pageTitle: string; + setMobileNavOpen: React.Dispatch>; } -function Nav({ sections, currentIndex, link: Link, pageTitle }: NavProps) { +function Nav({ + sections, + currentIndex, + link: Link, + pageTitle, + setMobileNavOpen, +}: NavProps) { return (

{pageTitle}

@@ -165,6 +174,7 @@ function Nav({ sections, currentIndex, link: Link, pageTitle }: NavProps) { className={classNames.join(" ")} id={section.id} key={section.id} + setMobileNavOpen={setMobileNavOpen} >
{section.title}
diff --git a/components/playground.tsx b/components/playground.tsx index d86e5b63..2ecaf442 100644 --- a/components/playground.tsx +++ b/components/playground.tsx @@ -205,9 +205,15 @@ export function OrganizedContentDemo() { const [id, setId] = useState(sections[0].id); - function FakeLink({ className, id, children }: LinkProps) { + function FakeLink({ className, id, children, setMobileNavOpen }: LinkProps) { return ( -
setId(id)}> +
{ + if (setMobileNavOpen) setMobileNavOpen(false); + setId(id); + }} + > {children}
);