From 1b5195908c23208db2a056f8a0d7b8b4132c3dce Mon Sep 17 00:00:00 2001 From: Corwin Smith Date: Tue, 6 Dec 2022 16:19:55 -0700 Subject: [PATCH 1/5] close mobile docs dropdown when page is selected --- src/components/UI/docs/DocsLinks.tsx | 7 ++++--- src/components/UI/docs/DocsNav.tsx | 16 ++++++++++++---- src/components/UI/docs/LinksList.tsx | 9 +++++---- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/components/UI/docs/DocsLinks.tsx b/src/components/UI/docs/DocsLinks.tsx index ab77e803ae..1eb9d48bf3 100644 --- a/src/components/UI/docs/DocsLinks.tsx +++ b/src/components/UI/docs/DocsLinks.tsx @@ -19,9 +19,10 @@ import { NavLink } from '../../../types'; interface Props { navLinks: NavLink[]; + updateMobileAccordionState: () => void; } -export const DocsLinks: FC = ({ navLinks }) => { +export const DocsLinks: FC = ({ navLinks, updateMobileAccordionState }) => { const router = useRouter(); const { slug } = router.query; return ( @@ -52,7 +53,7 @@ export const DocsLinks: FC = ({ navLinks }) => { _groupHover={{ background: 'primary', color: 'bg', textDecoration: 'none' }} > {to ? ( - + = ({ navLinks }) => { {items && ( - + )} diff --git a/src/components/UI/docs/DocsNav.tsx b/src/components/UI/docs/DocsNav.tsx index 3dcb661d4e..e086db3748 100644 --- a/src/components/UI/docs/DocsNav.tsx +++ b/src/components/UI/docs/DocsNav.tsx @@ -1,4 +1,4 @@ -import { FC } from 'react'; +import { FC, useState } from 'react'; import { Accordion, AccordionButton, @@ -17,14 +17,22 @@ interface Props { } export const DocsNav: FC = ({ navLinks }) => { + const OPEN = 0; + const CLOSED = -1; + const [mobileAccordionState, setMobileAccordionState] = useState(CLOSED) + + const updateMobileAccordionState = () => { + setMobileAccordionState(mobileAccordionState === OPEN ? CLOSED : OPEN) + } + return ( - + - + = ({ navLinks }) => { - + diff --git a/src/components/UI/docs/LinksList.tsx b/src/components/UI/docs/LinksList.tsx index 6c9d838e1d..ed2674204b 100644 --- a/src/components/UI/docs/LinksList.tsx +++ b/src/components/UI/docs/LinksList.tsx @@ -7,9 +7,10 @@ import { NavLink } from '../../../types'; interface LinksListProps { links: NavLink[]; + updateMobileAccordionState: () => void; } -export const LinksList: FC = ({ links }) => { +export const LinksList: FC = ({ links, updateMobileAccordionState }) => { const router = useRouter(); const { slug } = router.query; return ( @@ -19,7 +20,7 @@ export const LinksList: FC = ({ links }) => { const isActive = slug && split && split[split.length - 1] === slug[slug.length - 1]; return to ? ( - + = ({ links }) => { - {items && } + {items && } ) : ( {id} - {items && } + {items && } ); })} From 62aff31a2e987fb53cda7764910107cd99f6761a Mon Sep 17 00:00:00 2001 From: Corwin Smith Date: Mon, 12 Dec 2022 11:58:30 -0700 Subject: [PATCH 2/5] Update src/components/UI/docs/DocsNav.tsx Co-authored-by: Paul Wackerow <54227730+wackerow@users.noreply.github.com> --- src/components/UI/docs/DocsNav.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/UI/docs/DocsNav.tsx b/src/components/UI/docs/DocsNav.tsx index e086db3748..5bccc680c4 100644 --- a/src/components/UI/docs/DocsNav.tsx +++ b/src/components/UI/docs/DocsNav.tsx @@ -17,12 +17,10 @@ interface Props { } export const DocsNav: FC = ({ navLinks }) => { - const OPEN = 0; - const CLOSED = -1; - const [mobileAccordionState, setMobileAccordionState] = useState(CLOSED) + const [isMobileAccordionOpen, setIsMobileAccordionOpen] = useState(false) - const updateMobileAccordionState = () => { - setMobileAccordionState(mobileAccordionState === OPEN ? CLOSED : OPEN) + const toggleMobileAccordion = () => { + setMobileAccordionState(prev => !prev) } return ( From 657083d7f28b4671ee99016d4fde3a88319cb5e2 Mon Sep 17 00:00:00 2001 From: Corwin Smith Date: Mon, 12 Dec 2022 12:03:22 -0700 Subject: [PATCH 3/5] change requests --- src/components/UI/docs/DocsLinks.tsx | 8 ++++---- src/components/UI/docs/DocsNav.tsx | 8 ++++---- src/components/UI/docs/LinksList.tsx | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/UI/docs/DocsLinks.tsx b/src/components/UI/docs/DocsLinks.tsx index dcb8d1e3b9..fefa420555 100644 --- a/src/components/UI/docs/DocsLinks.tsx +++ b/src/components/UI/docs/DocsLinks.tsx @@ -19,10 +19,10 @@ import { NavLink } from '../../../types'; interface Props { navLinks: NavLink[]; - updateMobileAccordionState: () => void; + toggleMobileAccordion: () => void; } -export const DocsLinks: FC = ({ navLinks, updateMobileAccordionState }) => { +export const DocsLinks: FC = ({ navLinks, toggleMobileAccordion }) => { const router = useRouter(); const { slug } = router.query; return ( @@ -53,7 +53,7 @@ export const DocsLinks: FC = ({ navLinks, updateMobileAccordionState }) = _groupHover={{ background: 'primary', color: 'bg', textDecoration: 'none' }} > {to ? ( - + = ({ navLinks, updateMobileAccordionState }) = {items && ( - + )} diff --git a/src/components/UI/docs/DocsNav.tsx b/src/components/UI/docs/DocsNav.tsx index 5bccc680c4..91f8d37ce3 100644 --- a/src/components/UI/docs/DocsNav.tsx +++ b/src/components/UI/docs/DocsNav.tsx @@ -17,7 +17,7 @@ interface Props { } export const DocsNav: FC = ({ navLinks }) => { - const [isMobileAccordionOpen, setIsMobileAccordionOpen] = useState(false) + const [isMobileAccordionOpen, setMobileAccordionState] = useState(false) const toggleMobileAccordion = () => { setMobileAccordionState(prev => !prev) @@ -26,11 +26,11 @@ export const DocsNav: FC = ({ navLinks }) => { return ( - + - + = ({ navLinks }) => { - + diff --git a/src/components/UI/docs/LinksList.tsx b/src/components/UI/docs/LinksList.tsx index 152f720b11..ef6f027770 100644 --- a/src/components/UI/docs/LinksList.tsx +++ b/src/components/UI/docs/LinksList.tsx @@ -7,10 +7,10 @@ import { NavLink } from '../../../types'; interface LinksListProps { links: NavLink[]; - updateMobileAccordionState: () => void; + toggleMobileAccordion: () => void; } -export const LinksList: FC = ({ links, updateMobileAccordionState }) => { +export const LinksList: FC = ({ links, toggleMobileAccordion }) => { const router = useRouter(); const { slug } = router.query; return ( @@ -25,7 +25,7 @@ export const LinksList: FC = ({ links, updateMobileAccordionStat _hover={{ background: 'primary', color: 'bg' }} data-group > - + = ({ links, updateMobileAccordionStat - {items && } + {items && } ) : ( {id} - {items && } + {items && } ); })} From fbd09362f2a0d401fe0b93d20316a9110fb07fe3 Mon Sep 17 00:00:00 2001 From: Paul Wackerow <54227730+wackerow@users.noreply.github.com> Date: Mon, 12 Dec 2022 20:26:54 +0100 Subject: [PATCH 4/5] add legacyBehavior prop --- src/components/UI/docs/LinksList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/UI/docs/LinksList.tsx b/src/components/UI/docs/LinksList.tsx index ef6f027770..aec85947c6 100644 --- a/src/components/UI/docs/LinksList.tsx +++ b/src/components/UI/docs/LinksList.tsx @@ -25,7 +25,7 @@ export const LinksList: FC = ({ links, toggleMobileAccordion }) _hover={{ background: 'primary', color: 'bg' }} data-group > - + Date: Mon, 12 Dec 2022 12:01:20 -0800 Subject: [PATCH 5/5] fix onClick vs legacyBehavior adds missing legacyBehavior attribute to NextLink tags to prevent nesting anchor elements which was causing hydration warnings. Also fixes 'The legacy behavior requires onClick be set on the child of next/link' --- src/components/UI/docs/DocsLinks.tsx | 4 ++-- src/components/UI/docs/LinksList.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/UI/docs/DocsLinks.tsx b/src/components/UI/docs/DocsLinks.tsx index fefa420555..509236f7d9 100644 --- a/src/components/UI/docs/DocsLinks.tsx +++ b/src/components/UI/docs/DocsLinks.tsx @@ -53,8 +53,8 @@ export const DocsLinks: FC = ({ navLinks, toggleMobileAccordion }) => { _groupHover={{ background: 'primary', color: 'bg', textDecoration: 'none' }} > {to ? ( - - + + = ({ links, toggleMobileAccordion }) _hover={{ background: 'primary', color: 'bg' }} data-group > - - + +