Skip to content

Commit

Permalink
add title style to menu item
Browse files Browse the repository at this point in the history
  • Loading branch information
rushatgabhane committed May 6, 2024
1 parent 5497a13 commit 3adc309
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
22 changes: 20 additions & 2 deletions src/components/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ type MenuItemBaseProps = {
/** The fill color to pass into the secondary icon. */
secondaryIconFill?: string;

isSecondaryIconHoverable?: boolean;

/** Icon Width */
iconWidth?: number;

Expand Down Expand Up @@ -170,6 +172,12 @@ type MenuItemBaseProps = {
/** Text to display for the item */
title?: string;

/** Component to display as the title */
titleComponent?: ReactElement;

Check failure on line 176 in src/components/MenuItem.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Cannot find name 'ReactElement'. Did you mean 'SVGRectElement'?

/** Any additional styles to apply to the container for title components */
titleContainerStyle?: StyleProp<ViewStyle>;

/** A right-aligned subtitle for this menu option */
subtitle?: string | number;

Expand Down Expand Up @@ -285,6 +293,7 @@ function MenuItem(
secondaryIcon,
secondaryIconFill,
iconType = CONST.ICON_TYPE_ICON,
isSecondaryIconHoverable = false,
iconWidth,
iconHeight,
iconStyles,
Expand All @@ -302,6 +311,8 @@ function MenuItem(
focused = false,
disabled = false,
title,
titleComponent,
titleContainerStyle,
subtitle,
shouldShowBasicTitle,
label,
Expand Down Expand Up @@ -528,7 +539,13 @@ function MenuItem(
</View>
)}
{secondaryIcon && (
<View style={[styles.popoverMenuIcon, iconStyles]}>
<View
style={[
styles.popoverMenuIcon,
iconStyles,
isSecondaryIconHoverable && StyleUtils.getBackgroundAndBorderStyle(focused || isHovered ? theme.hoverComponentBG : theme.overlay),
]}
>
<Icon
contentFit={contentFit}
src={secondaryIcon}
Expand All @@ -540,7 +557,7 @@ function MenuItem(
/>
</View>
)}
<View style={[styles.justifyContentCenter, styles.flex1, StyleUtils.getMenuItemTextContainerStyle(isSmallAvatarSubscriptMenu)]}>
<View style={[styles.justifyContentCenter, styles.flex1, StyleUtils.getMenuItemTextContainerStyle(isSmallAvatarSubscriptMenu), titleContainerStyle]}>
{!!description && shouldShowDescriptionOnTop && (
<Text
style={descriptionTextStyles}
Expand Down Expand Up @@ -604,6 +621,7 @@ function MenuItem(
</Text>
</View>
)}
{titleComponent}
</View>
</View>
</View>
Expand Down
8 changes: 4 additions & 4 deletions src/components/ReportActionItem/TripDetailsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ function ReservationView({reservation}: ReservationViewProps) {

const formattedDate = getFormattedDate();

const bottomDescription = `${reservation.confirmations.length > 0 ? `${reservation.confirmations[0].value} • ` : ''}${
const bottomDescription = `${reservation.confirmations?.length > 0 ? `${reservation.confirmations[0].value} • ` : ''}${

Check failure on line 127 in src/components/ReportActionItem/TripDetailsView.tsx

View workflow job for this annotation

GitHub Actions / typecheck

'reservation.confirmations.length' is possibly 'undefined'.

Check failure on line 127 in src/components/ReportActionItem/TripDetailsView.tsx

View workflow job for this annotation

GitHub Actions / typecheck

'reservation.confirmations' is possibly 'undefined'.
reservation.type === CONST.RESERVATION_TYPE.FLIGHT
? `${reservation.company.longName}${reservation.company.shortName ?? ''} ${reservation.route.number}`
? `${reservation.company?.longName}${reservation?.company?.shortName ?? ''} ${reservation.route?.number}`
: reservation.start.address
}`;

Expand All @@ -148,7 +148,7 @@ function ReservationView({reservation}: ReservationViewProps) {
numberOfLines={1}
style={[styles.textNormalBold, styles.lh20]}
>
{reservation.company.longName}
{reservation.company?.longName}
</Text>
)}
<Text style={[styles.textSupportingSmallSize, styles.lh14]}>{bottomDescription}</Text>
Expand All @@ -158,7 +158,7 @@ function ReservationView({reservation}: ReservationViewProps) {
return (
<MenuItemWithTopDescription
description={formattedDate}
descriptionTextStyle={[styles.textLabelSupporting, styles.lh16, styles.tripDescriptionMargin]}
descriptionTextStyle={[styles.textLabelSupporting, styles.lh16]}
titleComponent={titleComponent}
titleContainerStyle={styles.justifyContentStart}
secondaryIcon={reservationIcon}
Expand Down

0 comments on commit 3adc309

Please sign in to comment.