Skip to content

Commit 48c12d4

Browse files
committed
replace the MdExpandMore with MdChevronRight icon to match the initial state and avoid the initial animation
1 parent 2630913 commit 48c12d4

File tree

2 files changed

+7
-25
lines changed

2 files changed

+7
-25
lines changed

src/components/SideNav.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { ReactNode, useEffect, useState } from "react"
1+
import { useEffect, useState } from "react"
22
import { motion } from "framer-motion"
33
import { useTranslation } from "next-i18next"
4-
import { MdExpandMore } from "react-icons/md"
4+
import { MdChevronRight } from "react-icons/md"
55
import { Box, HStack, Icon } from "@chakra-ui/react"
66

77
import { ChildOnlyProp } from "@/lib/types"
@@ -14,12 +14,11 @@ import docLinks from "../data/developer-docs-links.yaml"
1414
export const dropdownIconContainerVariant = {
1515
open: {
1616
rotate: 90,
17-
y: 3,
1817
transition: {
1918
duration: 0.4,
2019
},
2120
},
22-
closed: { rotate: 0, y: 0 },
21+
closed: { rotate: 0 },
2322
}
2423

2524
const innerLinksVariants = {
@@ -107,12 +106,7 @@ const NavLink = ({ item, path, isTopLevel }: NavLinkProps) => {
107106
cursor="pointer"
108107
display="flex"
109108
>
110-
<Icon
111-
as={MdExpandMore}
112-
transform="rotate(-90deg)"
113-
boxSize={6}
114-
color="secondary"
115-
/>
109+
<Icon as={MdChevronRight} boxSize={6} color="secondary" />
116110
</Box>
117111
</LinkContainer>
118112
<Box

src/components/SideNavMobile.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from "react"
22
import { AnimatePresence, motion } from "framer-motion"
33
import { useTranslation } from "next-i18next"
4-
import { MdExpandMore } from "react-icons/md"
4+
import { MdChevronRight } from "react-icons/md"
55
import { Box, Center, HStack, Icon } from "@chakra-ui/react"
66

77
import type { ChildOnlyProp, TranslationKey } from "@/lib/types"
@@ -113,14 +113,7 @@ const NavLink = ({ item, path, toggle }: NavLinkProps) => {
113113
variants={dropdownIconContainerVariant}
114114
animate={isOpen ? "open" : "closed"}
115115
>
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-
/>
116+
<Icon as={MdChevronRight} boxSize={6} color="secondary" />
124117
</Box>
125118
</LinkContainer>
126119
<Box
@@ -197,12 +190,7 @@ const SideNavMobile = ({ path }: SideNavMobileProps) => {
197190
variants={dropdownIconContainerVariant}
198191
animate={isOpen ? "open" : "closed"}
199192
>
200-
<Icon
201-
as={MdExpandMore}
202-
transform="rotate(-90deg)"
203-
boxSize={6}
204-
color="secondary"
205-
/>
193+
<Icon as={MdChevronRight} boxSize={6} color="secondary" />
206194
</Box>
207195
</Center>
208196
<AnimatePresence>

0 commit comments

Comments
 (0)