Skip to content

Commit

Permalink
Merge pull request #12380 from ethereum/nav-delay
Browse files Browse the repository at this point in the history
fix: nav item hover zone, opening delay duration
  • Loading branch information
nhsz authored Mar 6, 2024
2 parents 1b075bc + 48ee6c7 commit 45ef0d9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/components/Nav/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as NavigationMenu from "@radix-ui/react-navigation-menu"

import { Button } from "@/components/Buttons"

import { SECTION_LABELS } from "@/lib/constants"
import { NAV_PY, SECTION_LABELS } from "@/lib/constants"

import type { NavSections } from "../types"

Expand Down Expand Up @@ -32,6 +32,7 @@ const Menu = ({ sections, ...props }: NavMenuProps) => {
dir={direction}
orientation="horizontal"
onValueChange={handleSectionChange}
delayDuration={0}
>
<NavigationMenu.List asChild>
<UnorderedList display="flex" listStyleType="none" m="0">
Expand All @@ -47,6 +48,13 @@ const Menu = ({ sections, ...props }: NavMenuProps) => {
variant="ghost"
whiteSpace="nowrap"
color={isActive ? "primary.base" : "body.base"}
_after={{
content: '""',
position: "absolute",
insetInline: 0,
top: "100%",
height: NAV_PY,
}}
>
{/* Animated highlight for active section */}
{isActive && (
Expand Down
6 changes: 4 additions & 2 deletions src/components/Nav/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import LanguagePicker from "@/components/LanguagePicker"
import { BaseLink } from "@/components/Link"
import Search from "@/components/Search"

import { NAV_PY } from "@/lib/constants"

import Menu from "./Menu"
import MobileNavMenu from "./Mobile"
import { useNav } from "./useNav"
Expand Down Expand Up @@ -69,7 +71,7 @@ const Nav = () => {
borderColor="rgba(0, 0, 0, 0.1)"
height="4.75rem"
justifyContent="center"
py={4}
py={NAV_PY}
px={{ base: 4, xl: 8 }}
>
<Flex
Expand All @@ -94,7 +96,7 @@ const Nav = () => {
ms={{ base: 3, xl: 8 }}
>
<Menu hideBelow="md" sections={linkSections} />
<Flex alignItems="center"/* justifyContent="space-between" */>
<Flex alignItems="center" /* justifyContent="space-between" */>
<Search {...searchModalDisclosure} />
{/* Desktop */}
<HStack hideBelow="md" gap="0">
Expand Down
2 changes: 2 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,5 @@ export const SECTION_LABELS: NavSectionKey[] = [
"participate",
"research",
]

export const NAV_PY = 4

0 comments on commit 45ef0d9

Please sign in to comment.