diff --git a/apps/web/src/components/global/navbar/NavProductDropdownMenu.tsx b/apps/web/src/components/global/navbar/NavProductPopover.tsx similarity index 68% rename from apps/web/src/components/global/navbar/NavProductDropdownMenu.tsx rename to apps/web/src/components/global/navbar/NavProductPopover.tsx index edde69650..aa42ad8a1 100644 --- a/apps/web/src/components/global/navbar/NavProductDropdownMenu.tsx +++ b/apps/web/src/components/global/navbar/NavProductPopover.tsx @@ -1,9 +1,10 @@ import clsx from 'clsx'; -import React from 'react'; +import React, { useState } from 'react'; import { RiArrowDownSLine } from 'react-icons/ri'; +import { useDebounce } from 'usehooks-ts'; import LogoMark from '~/components/global/logos/LogoMark'; -import NavProductDropdownMenuContent from '~/components/global/navbar/NavProductDropdownMenuContent'; +import NavProductPopoverContent from '~/components/global/navbar/NavProductPopoverContent'; import Anchor from '~/components/ui/Anchor'; import Divider from '~/components/ui/Divider'; import Text, { textVariants } from '~/components/ui/Text'; @@ -18,7 +19,7 @@ import { import LogoComboMark from '../logos/LogoComboMark'; import { useProductMenuUnseenIndicator } from '../product-theme/useProductMenuUnseenIndicator'; -import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'; +import * as PopoverPrimitive from '@radix-ui/react-popover'; type ProductValue = 'interviews' | 'projects'; @@ -42,13 +43,24 @@ type Props = Readonly<{ variant: 'compact' | 'full'; }>; -export default function NavProductDropdownMenu({ +export default function NavProductPopover({ variant, product, triggerClassname, }: Props) { const { label } = labels[product]; const [showUnseenIndicator] = useProductMenuUnseenIndicator(); + const [open, setOpen] = useState(false); + // To debounce open state when quick hovering on and out + const debouncedOpen = useDebounce(open, 100); + + function handleMouseEnter() { + setOpen(true); + } + + function handleMouseLeave() { + setOpen(false); + } return (
- - + + - - - - - + + + + +
); } -export function NavProductDropdownMenuLogoOnly({ +export function NavProductPopoverLogoOnly({ product, triggerClassname, }: Readonly<{ @@ -124,10 +143,24 @@ export function NavProductDropdownMenuLogoOnly({ triggerClassname?: string; }>) { const [showUnseenIndicator] = useProductMenuUnseenIndicator(); + const [open, setOpen] = useState(false); + // To debounce open state when quick hovering on and out + const debouncedOpen = useDebounce(open, 100); + + function handleMouseEnter() { + setOpen(true); + } + + function handleMouseLeave() { + setOpen(false); + } return ( - - + + )} - - - - - + + + + + ); } diff --git a/apps/web/src/components/global/navbar/NavProductDropdownMenuContent.tsx b/apps/web/src/components/global/navbar/NavProductPopoverContent.tsx similarity index 71% rename from apps/web/src/components/global/navbar/NavProductDropdownMenuContent.tsx rename to apps/web/src/components/global/navbar/NavProductPopoverContent.tsx index 93329e3d7..6574ed68e 100644 --- a/apps/web/src/components/global/navbar/NavProductDropdownMenuContent.tsx +++ b/apps/web/src/components/global/navbar/NavProductPopoverContent.tsx @@ -19,11 +19,11 @@ import { import LogoComboMark from '../logos/LogoComboMark'; import { useProductMenuUnseenIndicator } from '../product-theme/useProductMenuUnseenIndicator'; -import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'; +import * as PopoverPrimitive from '@radix-ui/react-popover'; type ProductValue = 'interviews' | 'projects'; -function NavProductDropdownMenuItem({ +function NavProductMenuItem({ beta = false, href, label, @@ -37,8 +37,8 @@ function NavProductDropdownMenuItem({ showNewIndicator: boolean; }>) { return ( - - -
-
- - +
+
+ + + + {label} + + {showNewIndicator && ( + - - {label} - - {showNewIndicator && ( - - )} -
- {beta && ( - - - )}
- - + {beta && ( + + + + )} +
+ ); } -type Props = Readonly<{ product: ProductValue }>; +type Props = PopoverPrimitive.PopoverContentProps & + Readonly<{ + product: ProductValue; + }>; const roadmapLinks: Record = { interviews: '/interviews/roadmap', projects: '/projects/roadmap', }; -export default function NavProductDropdownMenuContent({ product }: Props) { +export default function NavProductPopoverContent({ product, ...props }: Props) { const items = useCommonNavItems(); const [showUnseenIndicator] = useProductMenuUnseenIndicator(); return ( - + sideOffset={8} + {...props}>
Products
- -
- + ); } diff --git a/apps/web/src/components/global/navbar/NavProductDropdownMenu_DEPRECATED.tsx b/apps/web/src/components/global/navbar/NavProductPopover_DEPRECATED.tsx similarity index 72% rename from apps/web/src/components/global/navbar/NavProductDropdownMenu_DEPRECATED.tsx rename to apps/web/src/components/global/navbar/NavProductPopover_DEPRECATED.tsx index 45f62de5c..ab23e3408 100644 --- a/apps/web/src/components/global/navbar/NavProductDropdownMenu_DEPRECATED.tsx +++ b/apps/web/src/components/global/navbar/NavProductPopover_DEPRECATED.tsx @@ -1,9 +1,11 @@ import clsx from 'clsx'; +import { useState } from 'react'; import { RiArrowDownSLine } from 'react-icons/ri'; +import { useDebounce } from 'usehooks-ts'; import LogoMark from '~/components/global/logos/LogoMark'; import ProjectsLogo from '~/components/global/logos/ProjectsLogo'; -import NavProductDropdownMenuContent from '~/components/global/navbar/NavProductDropdownMenuContent'; +import NavProductPopoverContent from '~/components/global/navbar/NavProductPopoverContent'; import { themeBackgroundElementEmphasizedStateColor_Hover, themeBackgroundElementPressedStateColor_Active, @@ -14,7 +16,7 @@ import { import { useProductMenuUnseenIndicator } from '../product-theme/useProductMenuUnseenIndicator'; -import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'; +import * as PopoverPrimitive from '@radix-ui/react-popover'; type Props = Readonly<{ product: 'interviews' | 'projects'; @@ -34,7 +36,7 @@ const buttonBaseClassname = clsx( themeBackgroundElementPressedStateColor_Active, ); -export default function NavProductDropdownMenu_DEPRECATED({ +export default function NavProductPopover_DEPRECATED({ variant, product, }: Props) { @@ -43,10 +45,24 @@ export default function NavProductDropdownMenu_DEPRECATED({ } const [showUnseenIndicator] = useProductMenuUnseenIndicator(); + const [open, setOpen] = useState(false); + // To debounce open state when quick hovering on and out + const debouncedOpen = useDebounce(open, 100); + + function handleMouseEnter() { + setOpen(true); + } + + function handleMouseLeave() { + setOpen(false); + } return ( - - + + {variant === 'full' ? (