Skip to content

Commit b17088f

Browse files
authored
Merge pull request #8928 from TylerAPfledderer/fix/toc-mobile-visibility
fix: apply dynamic visibility for mobile `TableOfContents`
2 parents 8d0f7e1 + 3329221 commit b17088f

File tree

1 file changed

+42
-38
lines changed

1 file changed

+42
-38
lines changed

src/components/TableOfContents/TableOfContentsMobile.tsx

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Flex,
77
Icon,
88
List,
9+
Show,
910
} from "@chakra-ui/react"
1011
import React from "react"
1112
import { MdExpandMore } from "react-icons/md"
@@ -27,46 +28,49 @@ const Mobile: React.FC<IPropsTableOfContentsMobile> = ({ items, maxDepth }) => {
2728
}
2829

2930
return (
30-
<Box
31-
as="aside"
32-
background="background"
33-
border="1px"
34-
borderColor="border"
35-
borderRadius="4px"
36-
py={2}
37-
px={4}
38-
>
39-
<Flex
40-
color="text200"
41-
cursor="pointer"
42-
alignItems="center"
43-
justify="space-between"
44-
{...getButtonProps()}
31+
<Show below="l">
32+
{/* TODO: switch `l` to `lg` after UI migration */}
33+
<Box
34+
as="aside"
35+
background="background"
36+
border="1px"
37+
borderColor="border"
38+
borderRadius="4px"
39+
py={2}
40+
px={4}
4541
>
46-
<chakra.span flex={1} fontWeight={500}>
47-
<Translation id="on-this-page" />
48-
</chakra.span>
49-
<Icon
50-
as={MdExpandMore}
51-
transform={isOpen ? "rotate(0)" : "rotate(-90deg)"}
52-
boxSize={6}
53-
transition="transform .4s"
54-
/>
55-
</Flex>
56-
<Fade
57-
in={isOpen}
58-
{...getDisclosureProps()}
59-
transition={{ enter: { duration: 0.6 } }}
60-
>
61-
<List {...outerListProps}>
62-
<ItemsList
63-
items={items}
64-
depth={0}
65-
maxDepth={maxDepth ? maxDepth : 1}
42+
<Flex
43+
color="text200"
44+
cursor="pointer"
45+
alignItems="center"
46+
justify="space-between"
47+
{...getButtonProps()}
48+
>
49+
<chakra.span flex={1} fontWeight={500}>
50+
<Translation id="on-this-page" />
51+
</chakra.span>
52+
<Icon
53+
as={MdExpandMore}
54+
transform={isOpen ? "rotate(0)" : "rotate(-90deg)"}
55+
boxSize={6}
56+
transition="transform .4s"
6657
/>
67-
</List>
68-
</Fade>
69-
</Box>
58+
</Flex>
59+
<Fade
60+
in={isOpen}
61+
{...getDisclosureProps()}
62+
transition={{ enter: { duration: 0.6 } }}
63+
>
64+
<List {...outerListProps}>
65+
<ItemsList
66+
items={items}
67+
depth={0}
68+
maxDepth={maxDepth ? maxDepth : 1}
69+
/>
70+
</List>
71+
</Fade>
72+
</Box>
73+
</Show>
7074
)
7175
}
7276

0 commit comments

Comments
 (0)