Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: nav item hover zone, opening delay duration #12380

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading