Merge pull request #134 from ethereum/documentationDropdownClose
[UX] - Interaction with documentation dropdown is confusing on mobile
This commit is contained in:
commit
82fdd696a2
@ -19,9 +19,10 @@ import { NavLink } from '../../../types';
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
navLinks: NavLink[];
|
navLinks: NavLink[];
|
||||||
|
toggleMobileAccordion: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DocsLinks: FC<Props> = ({ navLinks }) => {
|
export const DocsLinks: FC<Props> = ({ navLinks, toggleMobileAccordion }) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { slug } = router.query;
|
const { slug } = router.query;
|
||||||
return (
|
return (
|
||||||
@ -53,7 +54,7 @@ export const DocsLinks: FC<Props> = ({ navLinks }) => {
|
|||||||
>
|
>
|
||||||
{to ? (
|
{to ? (
|
||||||
<NextLink href={to} passHref legacyBehavior>
|
<NextLink href={to} passHref legacyBehavior>
|
||||||
<Link textDecoration='none !important'>
|
<Link textDecoration='none !important' onClick={toggleMobileAccordion}>
|
||||||
<Text
|
<Text
|
||||||
textStyle='docs-nav-dropdown'
|
textStyle='docs-nav-dropdown'
|
||||||
color={isActive ? 'primary' : 'unset'}
|
color={isActive ? 'primary' : 'unset'}
|
||||||
@ -89,7 +90,7 @@ export const DocsLinks: FC<Props> = ({ navLinks }) => {
|
|||||||
</AccordionButton>
|
</AccordionButton>
|
||||||
{items && (
|
{items && (
|
||||||
<AccordionPanel borderBottom='2px solid' borderColor='primary' px={0} py={4}>
|
<AccordionPanel borderBottom='2px solid' borderColor='primary' px={0} py={4}>
|
||||||
<LinksList links={items} />
|
<LinksList links={items} toggleMobileAccordion={toggleMobileAccordion} />
|
||||||
</AccordionPanel>
|
</AccordionPanel>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { FC } from 'react';
|
import { FC, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
Accordion,
|
Accordion,
|
||||||
AccordionButton,
|
AccordionButton,
|
||||||
@ -17,14 +17,20 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const DocsNav: FC<Props> = ({ navLinks }) => {
|
export const DocsNav: FC<Props> = ({ navLinks }) => {
|
||||||
|
const [isMobileAccordionOpen, setMobileAccordionState] = useState(false)
|
||||||
|
|
||||||
|
const toggleMobileAccordion = () => {
|
||||||
|
setMobileAccordionState(prev => !prev)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack w={{ base: '100%', lg: 72 }}>
|
<Stack w={{ base: '100%', lg: 72 }}>
|
||||||
<Stack display={{ base: 'none', lg: 'block' }}>
|
<Stack display={{ base: 'none', lg: 'block' }}>
|
||||||
<DocsLinks navLinks={navLinks} />
|
<DocsLinks navLinks={navLinks} toggleMobileAccordion={toggleMobileAccordion} />
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Stack display={{ base: 'block', lg: 'none' }}>
|
<Stack display={{ base: 'block', lg: 'none' }}>
|
||||||
<Accordion allowToggle>
|
<Accordion allowToggle index={isMobileAccordionOpen ? 0 : -1} onChange={toggleMobileAccordion}>
|
||||||
<AccordionItem border='none'>
|
<AccordionItem border='none'>
|
||||||
<AccordionButton
|
<AccordionButton
|
||||||
display='flex'
|
display='flex'
|
||||||
@ -49,7 +55,7 @@ export const DocsNav: FC<Props> = ({ navLinks }) => {
|
|||||||
<AccordionIcon />
|
<AccordionIcon />
|
||||||
</AccordionButton>
|
</AccordionButton>
|
||||||
<AccordionPanel p={0}>
|
<AccordionPanel p={0}>
|
||||||
<DocsLinks navLinks={navLinks} />
|
<DocsLinks navLinks={navLinks} toggleMobileAccordion={toggleMobileAccordion} />
|
||||||
</AccordionPanel>
|
</AccordionPanel>
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
@ -7,9 +7,10 @@ import { NavLink } from '../../../types';
|
|||||||
|
|
||||||
interface LinksListProps {
|
interface LinksListProps {
|
||||||
links: NavLink[];
|
links: NavLink[];
|
||||||
|
toggleMobileAccordion: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const LinksList: FC<LinksListProps> = ({ links }) => {
|
export const LinksList: FC<LinksListProps> = ({ links, toggleMobileAccordion }) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { slug } = router.query;
|
const { slug } = router.query;
|
||||||
return (
|
return (
|
||||||
@ -25,7 +26,7 @@ export const LinksList: FC<LinksListProps> = ({ links }) => {
|
|||||||
data-group
|
data-group
|
||||||
>
|
>
|
||||||
<NextLink href={to} passHref key={id} legacyBehavior>
|
<NextLink href={to} passHref key={id} legacyBehavior>
|
||||||
<Link textDecoration='none !important'>
|
<Link textDecoration='none !important' onClick={toggleMobileAccordion}>
|
||||||
<Text
|
<Text
|
||||||
textStyle='docs-nav-links'
|
textStyle='docs-nav-links'
|
||||||
color={items || isActive ? 'primary' : 'body'}
|
color={items || isActive ? 'primary' : 'body'}
|
||||||
@ -45,14 +46,14 @@ export const LinksList: FC<LinksListProps> = ({ links }) => {
|
|||||||
</Text>
|
</Text>
|
||||||
</Link>
|
</Link>
|
||||||
</NextLink>
|
</NextLink>
|
||||||
{items && <LinksList links={items} />}
|
{items && <LinksList links={items} toggleMobileAccordion={toggleMobileAccordion}/>}
|
||||||
</Stack>
|
</Stack>
|
||||||
) : (
|
) : (
|
||||||
<Stack key={id} pb={6}>
|
<Stack key={id} pb={6}>
|
||||||
<Text textStyle='docs-nav-links' color={items ? 'primary' : 'body'}>
|
<Text textStyle='docs-nav-links' color={items ? 'primary' : 'body'}>
|
||||||
{id}
|
{id}
|
||||||
</Text>
|
</Text>
|
||||||
{items && <LinksList links={items} />}
|
{items && <LinksList links={items} toggleMobileAccordion={toggleMobileAccordion} />}
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
Loading…
Reference in New Issue
Block a user