From c30bac946148a3205770be47c467552eb9bff049 Mon Sep 17 00:00:00 2001 From: Yossi Saadi Date: Thu, 2 May 2024 17:58:34 +0300 Subject: [PATCH 1/9] refactor(MenuItem): separate SubMenuIcon logic from MenuItem --- .../Menu/MenuItem/MenuItem.module.scss | 37 +-------------- .../src/components/Menu/MenuItem/MenuItem.tsx | 46 ++++--------------- .../MenuItemSubMenuIcon.module.scss | 32 +++++++++++++ .../MenuItemSubMenuIcon.tsx | 45 ++++++++++++++++++ .../MenuItemSubMenuIcon.types.ts | 6 +++ 5 files changed, 94 insertions(+), 72 deletions(-) create mode 100644 packages/core/src/components/Menu/MenuItem/components/MenuItemSubMenuIcon/MenuItemSubMenuIcon.module.scss create mode 100644 packages/core/src/components/Menu/MenuItem/components/MenuItemSubMenuIcon/MenuItemSubMenuIcon.tsx create mode 100644 packages/core/src/components/Menu/MenuItem/components/MenuItemSubMenuIcon/MenuItemSubMenuIcon.types.ts diff --git a/packages/core/src/components/Menu/MenuItem/MenuItem.module.scss b/packages/core/src/components/Menu/MenuItem/MenuItem.module.scss index e6735007c1..def371db39 100644 --- a/packages/core/src/components/Menu/MenuItem/MenuItem.module.scss +++ b/packages/core/src/components/Menu/MenuItem/MenuItem.module.scss @@ -17,45 +17,11 @@ .iconWrapper { margin-right: var(--spacing-small); -} - -.subMenuIconWrapper { - margin-left: var(--spacing-xs); -} - -.subMenuIconWrapper, -.iconWrapper { display: flex; align-items: center; justify-content: center; -} - -.subMenuIconWrapper .subMenuIcon, -.subMenuIconWrapper .icon, -.iconWrapper .subMenuIcon, -.iconWrapper .icon { - color: var(--icon-color); -} - -.subMenuIconWrapper .divider { - height: 19px; -} - -.subMenuIconWrapper .splitMenuItemIconButton { - width: 34px; - height: 30px; - - // TODO Temp override for Tal changes - remove once token is changed - --primary-background-hover-color: rgba(103, 104, 121, 0.1); - // Override for IconButton active color - --primary-selected-color: rgba(103, 104, 121, 0.1); -} - -.iconButton { - width: 18px; - height: 18px; - &:not(.disabled) { + .icon { color: var(--icon-color); } } @@ -69,7 +35,6 @@ color: var(--disabled-text-color); } -.item.disabled .subMenuIcon, .item.disabled .icon { cursor: not-allowed; color: var(--disabled-text-color); diff --git a/packages/core/src/components/Menu/MenuItem/MenuItem.tsx b/packages/core/src/components/Menu/MenuItem/MenuItem.tsx index 4600e158be..f8f9249831 100644 --- a/packages/core/src/components/Menu/MenuItem/MenuItem.tsx +++ b/packages/core/src/components/Menu/MenuItem/MenuItem.tsx @@ -30,11 +30,8 @@ import { TAB_INDEX_FOCUS_WITH_JS_ONLY, TooltipPosition } from "./MenuItemConstan import { CloseMenuOption, MenuChild } from "../Menu/MenuConstants"; import Label from "../../Label/Label"; import styles from "./MenuItem.module.scss"; -import { DropdownChevronRight } from "../../Icon/Icons"; -import IconButton from "../../IconButton/IconButton"; -import Divider from "../../Divider/Divider"; -import { DirectionType } from "../../Divider/DividerConstants"; import useIsMouseEnter from "../../../hooks/useIsMouseEnter"; +import MenuItemSubMenuIcon from "./components/MenuItemSubMenuIcon/MenuItemSubMenuIcon"; export interface MenuItemProps extends VibeComponentProps { title?: string; @@ -239,37 +236,6 @@ const MenuItem: VibeComponent & { // if "title" is a component ariaLabel is mandatory const iconLabel = ariaLabel ?? (title as string); - const renderSubMenuIconIfNeeded = () => { - if (!hasChildren) return null; - - return splitMenuItem ? ( -
- - -
- ) : ( -
- -
- ); - }; const [iconWrapperStyle, iconStyle] = useMemo(() => { return iconBackgroundColor @@ -364,7 +330,15 @@ const MenuItem: VibeComponent & { {label &&