From 8b92495418418e473404bcc1809cb4a1d0331f06 Mon Sep 17 00:00:00 2001 From: Innei Date: Wed, 17 Apr 2024 20:42:50 +0800 Subject: [PATCH] chore: adjust header popover menu item Signed-off-by: Innei --- .../layout/header/internal/MenuPopover.tsx | 41 ++++--------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/src/components/layout/header/internal/MenuPopover.tsx b/src/components/layout/header/internal/MenuPopover.tsx index a2cebf7fba..f420a3c3e6 100644 --- a/src/components/layout/header/internal/MenuPopover.tsx +++ b/src/components/layout/header/internal/MenuPopover.tsx @@ -1,19 +1,15 @@ 'use client' -import React, { memo, useId, useMemo, useState } from 'react' -import { m } from 'framer-motion' +import React, { memo } from 'react' import Link from 'next/link' import type { IHeaderMenu } from '../config' import { FloatPopover } from '~/components/ui/float-popover' -import { softSpringPreset } from '~/constants/spring' import { clsxm } from '~/lib/helper' export const MenuPopover: Component<{ subMenu: IHeaderMenu['subMenu'] }> = memo(({ children, subMenu }) => { - const currentId = useId() - const TriggerComponent = useMemo(() => () => children, [children]) if (!subMenu) return children return ( @@ -27,55 +23,32 @@ export const MenuPopover: Component<{ 'select-none rounded-xl bg-white/60 outline-none dark:bg-neutral-900/60', 'border border-zinc-900/5 shadow-lg shadow-zinc-800/5 backdrop-blur-md', 'dark:border-zinc-100/10 dark:from-zinc-900/70 dark:to-zinc-800/90', - 'relative flex w-[130px] flex-col py-1', + 'relative flex w-[130px] flex-col', 'focus-visible:!ring-0', ])} - TriggerComponent={TriggerComponent} + triggerElement={<>{children}} > {!!subMenu.length && subMenu.map((m) => { - return + return })} ) }) MenuPopover.displayName = 'MenuPopover' -const Item = memo(function Item( - props: IHeaderMenu & { - currentId: string - }, -) { - const { title, path, icon, currentId } = props +const Item = memo(function Item(props: IHeaderMenu) { + const { title, path, icon } = props - const [isEnter, setIsEnter] = useState(false) return ( { - setIsEnter(true) - }} - onMouseLeave={() => { - setIsEnter(false) - }} > {!!icon && {icon}} {title} - - {isEnter && ( - - )} ) })