diff --git a/packages/uikit/src/components/SubMenuItems/SubMenuItems.tsx b/packages/uikit/src/components/SubMenuItems/SubMenuItems.tsx index d0e58651bddab..3e8b6565c1b22 100644 --- a/packages/uikit/src/components/SubMenuItems/SubMenuItems.tsx +++ b/packages/uikit/src/components/SubMenuItems/SubMenuItems.tsx @@ -1,6 +1,6 @@ import { useIsomorphicLayoutEffect } from "framer-motion"; import debounce from "lodash/debounce"; -import React, { useCallback, useRef, useState } from "react"; +import React, { useCallback, useMemo, useRef, useState } from "react"; import { Box } from "../Box"; import { DropdownMenuItemType } from "../DropdownMenu/types"; import { AtomBox } from "../AtomBox"; @@ -15,6 +15,7 @@ import StyledSubMenuItems, { import { SubMenuItemsProps } from "./types"; import { FlexGap } from "../Layouts"; import NotificationDot from "../NotificationDot/NotificationDot"; +import { LinkStatus } from "../DropdownMenu/styles"; const SUBMENU_CHEVRON_CLICK_MOVE_PX = 100; const SUBMENU_SCROLL_DEVIATION = 3; @@ -44,7 +45,17 @@ const SubMenuItems: React.FC> = ({ else setRightClassName(""); }, []); - const hasLabeledItem = items.some((item) => !!item.LabelIcon); + const { hasHighlightedItem, highlightedItemColor } = useMemo(() => { + const anyLabelIcon = items.some((item) => !!item.LabelIcon); + if (anyLabelIcon) { + return { hasHighlightedItem: true, highlightedItemColor: "success" as const }; + } + const anyStatusIcon = items.find((item) => !!item.status); + if (anyStatusIcon) { + return { hasHighlightedItem: true, highlightedItemColor: anyStatusIcon?.status?.color || ("success" as const) }; + } + return { hasHighlightedItem: false, highlightedItemColor: "success" as const }; + }, [items]); useIsomorphicLayoutEffect(() => { layerController(); @@ -74,7 +85,7 @@ const SubMenuItems: React.FC> = ({ }} > {hasOverflowing && ( - + )} @@ -86,7 +97,7 @@ const SubMenuItems: React.FC> = ({ onScroll={debounce(layerController, 100)} ref={scrollLayerRef} > - {items.map(({ label, LabelIcon, href, icon, itemProps, type, disabled, onClick }) => { + {items.map(({ label, LabelIcon, status, href, icon, itemProps, type, disabled, onClick }) => { const Icon = icon; const isExternalLink = type === DropdownMenuItemType.EXTERNAL_LINK; const linkProps = isExternalLink @@ -115,6 +126,11 @@ const SubMenuItems: React.FC> = ({ {Icon && } {label} {LabelIcon ? : null} + {status && ( + + {status.text} + + )} {isExternalLink && ( diff --git a/packages/uikit/src/components/SubMenuItems/types.ts b/packages/uikit/src/components/SubMenuItems/types.ts index ef8e41cd138cf..9b66ee2d88fc5 100644 --- a/packages/uikit/src/components/SubMenuItems/types.ts +++ b/packages/uikit/src/components/SubMenuItems/types.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { ElementType } from "react"; import { FlexProps } from "../Box"; -import { DropdownMenuItemType } from "../DropdownMenu/types"; +import { DropdownMenuItemType, LinkStatus } from "../DropdownMenu/types"; export type SubMenuItemsType = { label: string; @@ -9,6 +9,7 @@ export type SubMenuItemsType = { itemProps?: any; icon?: ElementType; disabled?: boolean; + status?: LinkStatus; isMobileOnly?: boolean; type?: DropdownMenuItemType; onClick?: React.MouseEvent;