Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ type ButtonProps = Partial<ChildrenProps> & {

/** Whether the Enter keyboard listening is active whether or not the screen that contains the button is focused */
isPressOnEnterActive?: boolean;

/** The text displays under the first line */
secondLineText?: string;
};

type KeyboardShortcutComponentProps = Pick<ButtonProps, 'isDisabled' | 'isLoading' | 'onPress' | 'pressOnEnter' | 'allowBubble' | 'enterKeyEventListenerPriority' | 'isPressOnEnterActive'>;
Expand Down Expand Up @@ -246,6 +249,7 @@ function Button(
link = false,
isContentCentered = false,
isPressOnEnterActive,
secondLineText = '',
...rest
}: ButtonProps,
ref: ForwardedRef<View>,
Expand All @@ -260,7 +264,7 @@ function Button(
return rest.children;
}

const textComponent = (
const primaryText = (
<Text
numberOfLines={1}
style={[
Expand All @@ -273,6 +277,7 @@ function Button(
success && styles.buttonSuccessText,
danger && styles.buttonDangerText,
!!icon && styles.textAlignLeft,
!!secondLineText && styles.noPaddingBottom,
textStyles,
isHovered && textHoverStyles,
link && styles.link,
Expand All @@ -286,6 +291,15 @@ function Button(
</Text>
);

const textComponent = secondLineText ? (
<View style={[styles.alignItemsCenter, styles.flexColumn, styles.flexShrink1]}>
{primaryText}
<Text style={[isLoading && styles.opacity0, styles.pointerEventsNone, styles.fontWeightNormal, styles.textDoubleDecker]}>{secondLineText}</Text>
</View>
) : (
primaryText
);

const defaultFill = success || danger ? theme.textLight : theme.icon;

// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
Expand Down
3 changes: 3 additions & 0 deletions src/components/ButtonWithDropdownMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function ButtonWithDropdownMenu<IValueType>({
defaultSelectedIndex = 0,
shouldShowSelectedItemCheck = false,
testID,
secondLineText = '',
}: ButtonWithDropdownMenuProps<IValueType>) {
const theme = useTheme();
const styles = useThemeStyles();
Expand Down Expand Up @@ -144,6 +145,7 @@ function ButtonWithDropdownMenu<IValueType>({
shouldShowRightIcon={!isSplitButton}
isSplitButton={isSplitButton}
testID={testID}
secondLineText={secondLineText}
/>

{isSplitButton && (
Expand Down Expand Up @@ -193,6 +195,7 @@ function ButtonWithDropdownMenu<IValueType>({
small={buttonSize === CONST.DROPDOWN_BUTTON_SIZE.SMALL}
innerStyles={[innerStyleDropButton]}
enterKeyEventListenerPriority={enterKeyEventListenerPriority}
secondLineText={secondLineText}
/>
)}
{(shouldAlwaysShowDropdownMenu || options.length > 1) && !!popoverAnchorPosition && (
Expand Down
3 changes: 3 additions & 0 deletions src/components/ButtonWithDropdownMenu/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ type ButtonWithDropdownMenuProps<TValueType> = {

/** Used to locate the component in the tests */
testID?: string;

/** The second line text displays under the first line */
secondLineText?: string;
};

export type {
Expand Down
10 changes: 9 additions & 1 deletion src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,15 @@ const styles = (theme: ThemeColors) =>
...FontUtils.fontFamily.platform.EXP_NEUE,
fontSize: variables.fontSizeExtraSmall,
},

textDoubleDecker: {
fontSize: variables.fontSizeSmall,
opacity: 0.8,
fontWeight: FontUtils.fontWeight.bold,
lineHeight: 12,
},
noPaddingBottom: {
paddingBottom: 0,
},
textNormal: {
fontSize: variables.fontSizeNormal,
},
Expand Down