Skip to content

Commit e7bc5de

Browse files
authored
Merge pull request #12125 from ethereum/nav-menu-radix-ui
Nav menu - redesign implementation
2 parents 8473987 + 906078d commit e7bc5de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+10470
-2014
lines changed

netlify.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@
2222
"./src/intl/**/*",
2323
"!./public/**/*",
2424
"!./node_modules/@swc/core-linux-x64-musl/**/*",
25+
"!./node_modules/@swc/core-linux-x64-gnu/**/*",
2526
]

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@docsearch/react": "^3.5.2",
2626
"@emotion/react": "^11.11.1",
2727
"@emotion/styled": "^11.11.0",
28+
"@radix-ui/react-navigation-menu": "^1.1.4",
2829
"@socialgouv/matomo-next": "^1.8.0",
2930
"clipboard": "^2.0.11",
3031
"embla-carousel-react": "^7.0.0",

src/@chakra-ui/foundations/spacing.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const spacing = {
22
7.5: "1.875rem",
33
10.5: "2.625rem",
4+
19: "4.75rem", // Nav height
45
}
56

67
export default spacing

src/@chakra-ui/semanticTokens.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ const semanticTokens = {
105105
"linear-gradient(102.7deg, rgba(185, 185, 241, 0.2) 0%, rgba(84, 132, 234, 0.2) 51.56%, rgba(58, 142, 137, 0.2) 100%)",
106106
},
107107
},
108+
shadows: {
109+
menu: {
110+
accordion:
111+
"0px 2px 2px 0px rgba(0, 0, 0, 0.12) inset, 0px -3px 2px 0px rgba(0, 0, 0, 0.14) inset",
112+
},
113+
},
108114
}
109115

110116
export default semanticTokens

src/components/LanguagePicker/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const LanguagePicker = ({
7171
{/* Mobile Close bar */}
7272
<Flex
7373
justifyContent="end"
74-
hideFrom="lg" // TODO: Confirm breakpoint after nav-menu PR merged
74+
hideFrom="md"
7575
position="sticky"
7676
zIndex="sticky"
7777
top="0"
@@ -139,7 +139,7 @@ const LanguagePicker = ({
139139
}}
140140
/>
141141
<InputRightElement
142-
hideBelow="lg" // TODO: Confirm breakpoint after nav-menu PR merged
142+
hideBelow="md"
143143
cursor="text"
144144
>
145145
<Kbd

src/components/Nav/Dropdown.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Box, Fade, Flex, Icon, ListItem } from "@chakra-ui/react"
44

55
import { BaseLink, type LinkProps } from "../Link"
66

7-
import { ISection } from "./types"
7+
import { NavSectionDetail } from "./types"
88

99
import { useOnClickOutside } from "@/hooks/useOnClickOutside"
1010

@@ -41,7 +41,7 @@ const DropdownContext = React.createContext<DropdownContext | null>(null)
4141

4242
export type NavDropdownProps = {
4343
children?: React.ReactNode
44-
section: ISection
44+
section: NavSectionDetail
4545
}
4646

4747
const NavDropdown = ({ children, section }: NavDropdownProps) => {
@@ -72,7 +72,7 @@ const NavDropdown = ({ children, section }: NavDropdownProps) => {
7272
}
7373
}
7474

75-
const ariaLabel = section.ariaLabel || section.text
75+
const ariaLabel = section.ariaLabel || section.label
7676

7777
return (
7878
<DropdownContext.Provider
@@ -102,7 +102,7 @@ const NavDropdown = ({ children, section }: NavDropdownProps) => {
102102
},
103103
}}
104104
>
105-
{section.text}
105+
{section.label}
106106
<Icon
107107
as={MdExpandMore}
108108
color="text200"

src/components/Nav/Menu.tsx

Lines changed: 0 additions & 100 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { useRouter } from "next/router"
2+
import { Box, Text } from "@chakra-ui/react"
3+
4+
import { cleanPath } from "@/lib/utils/url"
5+
6+
import type { Level, NavItem } from "../types"
7+
8+
import { useNavMenuColors } from "@/hooks/useNavMenuColors"
9+
10+
type ItemProps = {
11+
item: NavItem
12+
lvl: Level
13+
}
14+
15+
const ItemContent = ({ item, lvl }: ItemProps) => {
16+
const { label, description, icon, ...action } = item
17+
const { asPath } = useRouter()
18+
const menuColors = useNavMenuColors()
19+
20+
const isLink = "href" in action
21+
const isActivePage = isLink && cleanPath(asPath) === action.href
22+
23+
return (
24+
<Box me="auto" textAlign="start" position="relative">
25+
<Text fontWeight="bold" color={menuColors.body}>
26+
{label}
27+
</Text>
28+
<Text
29+
fontSize="sm"
30+
color={isActivePage ? menuColors.body : menuColors.lvl[lvl].subtext}
31+
>
32+
{description}
33+
</Text>
34+
</Box>
35+
)
36+
}
37+
38+
export default ItemContent
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { useRouter } from "next/router"
2+
import { MdChevronLeft, MdChevronRight } from "react-icons/md"
3+
import { Icon,type IconProps } from "@chakra-ui/react"
4+
5+
import type { Lang } from "@/lib/types"
6+
7+
import { isLangRightToLeft } from "@/lib/utils/translations"
8+
9+
const NextChevron = (props: IconProps) => {
10+
const { locale } = useRouter()
11+
const isRtl = isLangRightToLeft(locale! as Lang)
12+
return <Icon as={isRtl ? MdChevronLeft : MdChevronRight} {...props} />
13+
}
14+
15+
export default NextChevron

0 commit comments

Comments
 (0)