Skip to content

Commit 994ae9a

Browse files
authored
Merge pull request Expensify#68454 from samranahm/67445/add-styling-to-rightIcon
fix: add styling to right icon in menu item
2 parents 97ceb10 + 1ce10fd commit 994ae9a

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

src/components/MenuItem.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ type MenuItemBaseProps = {
104104
descriptionTextStyle?: StyleProp<TextStyle>;
105105

106106
/** The fill color to pass into the icon. */
107-
iconFill?: string;
107+
iconFill?: string | ((isHovered: boolean) => string);
108108

109109
/** Secondary icon to display on the left side of component, right of the icon */
110110
secondaryIcon?: IconAsset;
@@ -377,6 +377,9 @@ type MenuItemBaseProps = {
377377

378378
/** Report ID for the avatar on the right */
379379
rightIconReportID?: string;
380+
381+
/** Whether the menu item contains nested submenu items. */
382+
hasSubMenuItems?: boolean;
380383
};
381384

382385
type MenuItemProps = (IconProps | AvatarProps | NoIcon) & MenuItemBaseProps;
@@ -498,6 +501,7 @@ function MenuItem(
498501
shouldTeleportPortalToModalLayer,
499502
copyValue,
500503
plaidUrl,
504+
hasSubMenuItems = false,
501505
}: MenuItemProps,
502506
ref: PressableRef,
503507
) {
@@ -755,14 +759,17 @@ function MenuItem(
755759
width={iconWidth}
756760
height={iconHeight}
757761
fill={
762+
// eslint-disable-next-line no-nested-ternary
758763
displayInDefaultIconColor
759764
? undefined
760-
: (iconFill ??
761-
StyleUtils.getIconFillColor(
762-
getButtonState(focused || isHovered, pressed, success, disabled, interactive),
763-
true,
764-
isPaneMenu,
765-
))
765+
: typeof iconFill === 'function'
766+
? iconFill(isHovered)
767+
: (iconFill ??
768+
StyleUtils.getIconFillColor(
769+
getButtonState(focused || isHovered, pressed, success, disabled, interactive),
770+
true,
771+
isPaneMenu,
772+
))
766773
}
767774
additionalStyles={additionalIconStyles}
768775
/>
@@ -936,11 +943,15 @@ function MenuItem(
936943
styles.pointerEventsAuto,
937944
StyleUtils.getMenuItemIconStyle(isCompact),
938945
disabled && !shouldUseDefaultCursorWhenDisabled && styles.cursorDisabled,
946+
hasSubMenuItems && styles.opacitySemiTransparent,
947+
hasSubMenuItems && styles.pl6,
939948
]}
940949
>
941950
<Icon
942951
src={iconRight}
943952
fill={StyleUtils.getIconFillColor(getButtonState(focused || isHovered, pressed, success, disabled, interactive))}
953+
width={hasSubMenuItems ? variables.iconSizeSmall : variables.iconSizeNormal}
954+
height={hasSubMenuItems ? variables.iconSizeSmall : variables.iconSizeNormal}
944955
/>
945956
</View>
946957
)}

src/components/PopoverMenu.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
1616
import useWindowDimensions from '@hooks/useWindowDimensions';
1717
import {isSafari} from '@libs/Browser';
1818
import getPlatform from '@libs/getPlatform';
19+
import variables from '@styles/variables';
1920
import {close} from '@userActions/Modal';
2021
import CONST from '@src/CONST';
2122
import type {AnchorPosition} from '@src/styles';
@@ -290,8 +291,9 @@ function BasePopoverMenu({
290291
<MenuItem
291292
key={previouslySelectedItem?.text}
292293
icon={Expensicons.BackArrow}
293-
iconFill={theme.icon}
294+
iconFill={(isHovered) => (isHovered ? theme.iconHovered : theme.icon)}
294295
style={hasBackButtonText ? styles.pv0 : undefined}
296+
additionalIconStyles={[{width: variables.iconSizeSmall, height: variables.iconSizeSmall}, styles.opacitySemiTransparent, styles.mr1]}
295297
title={hasBackButtonText ? previouslySelectedItem?.backButtonText : previouslySelectedItem?.text}
296298
titleStyle={hasBackButtonText ? styles.createMenuHeaderText : undefined}
297299
shouldShowBasicTitle={hasBackButtonText}
@@ -340,6 +342,7 @@ function BasePopoverMenu({
340342
titleStyle={StyleSheet.flatten([styles.flex1, item.titleStyle])}
341343
// Spread other props dynamically
342344
{...menuItemProps}
345+
hasSubMenuItems={!!subMenuItems?.length}
343346
shouldShowLoadingSpinnerIcon={shouldShowLoadingSpinnerIcon}
344347
/>
345348
</OfflineWithFeedback>

0 commit comments

Comments
 (0)