Skip to content

Commit

Permalink
Merge pull request #594 from easyops-cn/sailorshe/master/fixPopoverAn…
Browse files Browse the repository at this point in the history
…dnavMenuOverflowStyle

fix(): nav-menu & popover style
  • Loading branch information
weareoutman authored Nov 8, 2023
2 parents 00430a7 + 50fad73 commit c9425c5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 deletions.
10 changes: 6 additions & 4 deletions bricks/basic/src/popover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function PopoverComponent(props: PopoverComponentProps) {
scale: 0.9,
},
],
{ duration: 300, easing: "ease" }
{ duration: 100, easing: "ease" }
));

!visible && (popover.active = visible);
Expand Down Expand Up @@ -268,9 +268,11 @@ function PopoverComponent(props: PopoverComponentProps) {
() => !visible && handleVisibleChange(true),
[visible, handleVisibleChange]
);
const handlePopoverClose = useCallback(() => {
handleVisibleChange(false);
}, [handleVisibleChange]);

const handlePopoverClose = useCallback(
() => handleVisibleChange(false),
[handleVisibleChange]
);

const handleNotTrigger = (e: MouseEvent) => {
e.stopPropagation();
Expand Down
38 changes: 28 additions & 10 deletions bricks/nav/src/nav-menu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import React, { CSSProperties, useEffect, useRef, useState } from "react";
import React, {
CSSProperties,
useEffect,
useMemo,
useRef,
useState,
} from "react";
import { createDecorators } from "@next-core/element";
import { getHistory } from "@next-core/runtime";
import { ReactNextElement, wrapBrick } from "@next-core/react-element";
Expand Down Expand Up @@ -67,6 +73,7 @@ interface MenuItemComProps {
topData?: boolean;
selectedKey?: string[];
showTooltip?: boolean;
overflow?: boolean;
}
interface SimpleMenuItemComProps extends MenuItemComProps {
item: SidebarMenuSimpleItem;
Expand Down Expand Up @@ -123,6 +130,7 @@ function SubMenuItemCom({
topData,
showTooltip,
selectedKey = [],
overflow,
}: MenuGroupComProps) {
return item.items?.length > 0 ? (
<WrappedPopover
Expand All @@ -145,7 +153,11 @@ function SubMenuItemCom({
>
{renderSpanCom(item, !topData)}
</WrappedMenuItem>
<div className="sub-menu-wrapper">
<div
className={classnames("sub-menu-wrapper", {
"overflow-menu-wrapper": overflow,
})}
>
{item.items.map((innerItem) => (
<React.Fragment key={innerItem.key}>
<RenderMenuItemCom
Expand Down Expand Up @@ -424,6 +436,18 @@ function NavMenuComponent(props: NavMenuProps) {
}
}, []);

const overflowMenu = useMemo(
(): SidebarMenuItem => ({
type: "subMenu",
title: "···",
items: menu?.menuItems.slice(
overflowIndex,
menu.menuItems.length
) as SidebarMenuItem[],
}),
[menu?.menuItems, overflowIndex]
);

return (
<div ref={navMenuWrapperRef} className="nav-menu-wrapper">
{menu?.menuItems.map((item, index) => {
Expand Down Expand Up @@ -465,16 +489,10 @@ function NavMenuComponent(props: NavMenuProps) {
})}
<RenderMenuItemCom
hidden={overflowIndex > (menu?.menuItems?.length ?? 0)}
item={{
type: "subMenu",
title: "···",
items: menu?.menuItems.slice(
overflowIndex,
menu.menuItems.length
) as SidebarMenuItem[],
}}
item={overflowMenu}
showTooltip={showTooltip}
selectedKey={selectedKey}
overflow={true}
topData={true}
/>
</div>
Expand Down
5 changes: 5 additions & 0 deletions bricks/nav/src/nav-menu/nav-menu.shadow.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ eo-link {
overflow-y: auto;
}

.overflow-menu-wrapper {
display: flex;
flex-direction: column;
}

.sub-menu-wrapper > eo-menu-item {
display: block;
width: 100%;
Expand Down

0 comments on commit c9425c5

Please sign in to comment.