Skip to content

Commit 2630913

Browse files
committed
update dropdown icon rotation in SideNavMobile component
1 parent bdd9147 commit 2630913

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

src/components/SideNav.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import docLinks from "../data/developer-docs-links.yaml"
1313

1414
export const dropdownIconContainerVariant = {
1515
open: {
16-
rotate: 0,
16+
rotate: 90,
1717
y: 3,
1818
transition: {
1919
duration: 0.4,
2020
},
2121
},
22-
closed: { rotate: -90, y: 0 },
22+
closed: { rotate: 0, y: 0 },
2323
}
2424

2525
const innerLinksVariants = {
@@ -105,8 +105,14 @@ const NavLink = ({ item, path, isTopLevel }: NavLinkProps) => {
105105
variants={dropdownIconContainerVariant}
106106
animate={isOpen ? "open" : "closed"}
107107
cursor="pointer"
108+
display="flex"
108109
>
109-
<Icon as={MdExpandMore} boxSize={6} color="secondary" />
110+
<Icon
111+
as={MdExpandMore}
112+
transform="rotate(-90deg)"
113+
boxSize={6}
114+
color="secondary"
115+
/>
110116
</Box>
111117
</LinkContainer>
112118
<Box

src/components/SideNavMobile.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,19 @@ const NavLink = ({ item, path, toggle }: NavLinkProps) => {
108108
<Box
109109
as={motion.div}
110110
cursor="pointer"
111+
display="flex"
111112
onClick={() => setIsOpen(!isOpen)}
112113
variants={dropdownIconContainerVariant}
113114
animate={isOpen ? "open" : "closed"}
114115
>
115-
<Icon as={MdExpandMore} boxSize={6} color="secondary" />
116+
<Icon
117+
as={MdExpandMore}
118+
// display by default the icon in this position `>` (close state)
119+
// this will prevent the icon from rotating when the page loads
120+
transform="rotate(-90deg)"
121+
boxSize={6}
122+
color="secondary"
123+
/>
116124
</Box>
117125
</LinkContainer>
118126
<Box
@@ -185,10 +193,16 @@ const SideNavMobile = ({ path }: SideNavMobileProps) => {
185193
<Box
186194
as={motion.div}
187195
cursor="pointer"
196+
display="flex"
188197
variants={dropdownIconContainerVariant}
189198
animate={isOpen ? "open" : "closed"}
190199
>
191-
<Icon as={MdExpandMore} boxSize={6} color="secondary" />
200+
<Icon
201+
as={MdExpandMore}
202+
transform="rotate(-90deg)"
203+
boxSize={6}
204+
color="secondary"
205+
/>
192206
</Box>
193207
</Center>
194208
<AnimatePresence>

0 commit comments

Comments
 (0)