Skip to content
Open
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
43 changes: 22 additions & 21 deletions src/components/AnimatedSubmitButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Button from '@components/Button';
import Button from '@components/ButtonComposed';

import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
Expand All @@ -22,28 +22,28 @@ import Animated, {Keyframe, useAnimatedStyle, useSharedValue, withTiming} from '
import {scheduleOnRN} from 'react-native-worklets';

type AnimatedSubmitButtonProps = WithSentryLabel & {
// Whether to show the success state
success: boolean | undefined;
/** Submit buttons support the default and success styles; danger is not a valid submit state. */
variant?: typeof CONST.BUTTON_VARIANT.SUCCESS;

// Text to show on the button
/** Text to show on the button */
text: string;

// Function to call when the button is pressed
/** Function to call when the button is pressed */
onPress: () => void;

// Whether the animation is running
/** Whether the animation is running */
isSubmittingAnimationRunning: boolean;

// Function to call when the animation finishes
/** Function to call when the animation finishes */
onAnimationFinish: () => void;

// Whether the button should be disabled
/** Whether the button should be disabled */
isDisabled?: boolean;

// Whether this is a DEW submission that needs backend validation before showing "Submitted"
/** Whether this is a DEW submission that needs backend validation before showing "Submitted" */
isDEWSubmission?: boolean;

// The report id for which the button is displayed
/** The report id for which the button is displayed */
reportID?: string;

/** Whether to show "Mark as done" copy instead of "Submit" copy for track-intent users */
Expand All @@ -53,7 +53,7 @@ type AnimatedSubmitButtonProps = WithSentryLabel & {
const pendingExpenseActionSelector = (reportMetadata: OnyxEntry<ReportMetadata>) => reportMetadata?.pendingExpenseAction;

function AnimatedSubmitButton({
success,
variant,
text,
onPress,
isSubmittingAnimationRunning,
Expand Down Expand Up @@ -110,7 +110,6 @@ function AnimatedSubmitButton({
[buttonDuration, stretchOutY],
);
const icons = useMemoizedLazyExpensifyIcons(['Send']);
const icon = isAnimationRunning ? icons.Send : null;

useEffect(() => {
if (!isAnimationRunning) {
Expand Down Expand Up @@ -159,6 +158,7 @@ function AnimatedSubmitButton({

// eslint-disable-next-line react-hooks/refs
const showLoading = isShowingLoading || (isAnimationRunning && (!viewRef.current || (isDEWSubmission && !isDEWSubmissionComplete)));
const shouldShowIcon = isAnimationRunning && !showLoading;

return (
<Animated.View style={[containerStyles, {minWidth}]}>
Expand All @@ -170,24 +170,25 @@ function AnimatedSubmitButton({
exiting={buttonAnimation}
>
<Button
success={success}
text={showLoading ? text : translate(isMarkAsDone ? 'common.markedAsDoneStatus' : 'common.submitted')}
variant={variant}
isLoading={showLoading}
icon={!showLoading ? icon : undefined}
isDisabled
shouldStayNormalOnDisable
/>
stayNormalOnDisable
>
{shouldShowIcon && <Button.Icon src={icons.Send} />}
<Button.Text>{shouldShowIcon ? translate(isMarkAsDone ? 'common.markedAsDoneStatus' : 'common.submitted') : text}</Button.Text>
</Button>
</Animated.View>
)}
{!isAnimationRunning && (
<Button
success={success}
text={text}
variant={variant}
onPress={onPress}
icon={icon}
isDisabled={isDisabled}
sentryLabel={sentryLabel}
/>
>
<Button.Text>{text}</Button.Text>
</Button>
)}
</Animated.View>
);
Expand Down
28 changes: 18 additions & 10 deletions src/components/Attachments/AttachmentCarousel/CarouselButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {Attachment} from '@components/Attachments/types';
import Button from '@components/Button';
import Button from '@components/ButtonComposed';
import Tooltip from '@components/Tooltip';

import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
Expand Down Expand Up @@ -51,31 +51,39 @@ function CarouselButtons({page, attachments, shouldShowArrows, onBack, onForward
<Tooltip text={translate('common.previous')}>
<View style={[styles.attachmentArrow, shouldUseNarrowLayout ? styles.l2 : styles.l8]}>
<Button
small
innerStyles={[styles.arrowIcon]}
icon={icons.BackArrow}
iconFill={theme.text}
size={CONST.BUTTON_SIZE.SMALL}
innerStyles={styles.arrowIcon}
onPress={onBack}
onPressIn={cancelAutoHideArrow}
onPressOut={autoHideArrow}
sentryLabel={CONST.SENTRY_LABEL.ATTACHMENT_CAROUSEL.PREVIOUS_BUTTON}
/>
>
<Button.Icon
src={icons.BackArrow}
fill={theme.text}
hoverFill={theme.text}
/>
Comment on lines +61 to +65

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI sent me a message like this. Check if it really looks wrong; if so, we should fix it now during the migration.

ButtonIcon does const propsFill = isHovered ? hoverFill : fill; and then fill={propsFill ?? defaultFill} (src/components/ButtonComposed/primitives/ButtonIcon.tsx:38-43). Passing fill without hoverFill therefore falls back to the theme default on hover.

Here the carousel arrows go from theme.text (#002E22 in light) to theme.buttonIcon (#A2A9A3) when hovered. In ReceiptPreviews the white arrow on the green circle turns grey.

To be clear: this is not a regression - the legacy Button had the identical fallback (isHovered ? (iconHoverFill ?? defaultFill) : (iconFill ?? defaultFill), src/components/Button/index.tsx:401). But this PR touches exactly these lines, so it is a cheap moment to add hoverFill (or to fix ButtonIcon to (isHovered ? hoverFill ?? fill : fill) ?? defaultFill).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find, we should look into it 👀

</Button>
</View>
</Tooltip>
)}
{!isForwardDisabled && (
<Tooltip text={translate('common.next')}>
<View style={[styles.attachmentArrow, shouldUseNarrowLayout ? styles.r2 : styles.r8]}>
<Button
small
size={CONST.BUTTON_SIZE.SMALL}
innerStyles={[styles.arrowIcon]}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT:

Suggested change
innerStyles={[styles.arrowIcon]}
innerStyles={styles.arrowIcon}

icon={icons.ArrowRight}
iconFill={theme.text}
onPress={onForward}
onPressIn={cancelAutoHideArrow}
onPressOut={autoHideArrow}
sentryLabel={CONST.SENTRY_LABEL.ATTACHMENT_CAROUSEL.NEXT_BUTTON}
/>
>
<Button.Icon
src={icons.ArrowRight}
fill={theme.text}
hoverFill={theme.text}
/>
</Button>
</View>
</Tooltip>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AttachmentView from '@components/Attachments/AttachmentView';
import type {Attachment} from '@components/Attachments/types';
import Button from '@components/Button';
import Button from '@components/ButtonComposed';
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';
import SafeAreaConsumer from '@components/SafeAreaConsumer';
import Text from '@components/Text';
Expand Down Expand Up @@ -48,8 +48,10 @@ function CarouselItem({item, onPress, isFocused, isModalHovered, reportID}: Caro

const renderButton = (style: StyleProp<ViewStyle>) => (
<Button

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On main the raw Text was a child of a column container, so a long label wrapped. ButtonComposed wraps children in a flexRow and row items default to flexShrink: 0, so it now overflows instead. Button.Text sets flexShrink1 for this reason. Low risk with these short labels, but worth a check in de and a styles.flexShrink1 if it overflows. Same in ChatMessageContent.tsx:96 and ChronosOOOListActions.tsx:69.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I tested all three buttons in German and with an artificially long label and saw no overflow, so I decided I'll leave it as it is

small
size={CONST.BUTTON_SIZE.SMALL}
style={style}
// Restores the 12px horizontal padding from the legacy implementation.
innerStyles={styles.ph3}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a short comment, for example:

// Raw children skip ButtonText and the ph1 it contributes, so the legacy 12px horizontal padding is restored here.
innerStyles={styles.ph3}

onPress={() => setIsHidden(!isHidden)}
testID="moderationButton"
sentryLabel={CONST.SENTRY_LABEL.ATTACHMENT_CAROUSEL.MODERATION_BUTTON}
Expand Down
9 changes: 5 additions & 4 deletions src/components/Attachments/AttachmentView/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {useAttachmentCarouselPagerActions} from '@components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPagerContext';
import MultiGestureIcon from '@components/Attachments/MultiGestureIcon';
import type {Attachment, AttachmentSource} from '@components/Attachments/types';
import Button from '@components/Button';
import Button from '@components/ButtonComposed';
import DistanceEReceipt from '@components/DistanceEReceipt';
import EReceipt from '@components/EReceipt';
import Icon from '@components/Icon';
Expand Down Expand Up @@ -346,16 +346,17 @@ function AttachmentView({
<Text style={[styles.notFoundTextHeader]}>{translate('attachmentView.attachmentNotFound')}</Text>
</View>
<Button
text={translate('attachmentView.retry')}
icon={icons.ArrowCircleClockwise}
onPress={() => {
if (isOffline) {
return;
}
setImageError(false);
}}
sentryLabel={CONST.SENTRY_LABEL.ATTACHMENT_CAROUSEL.RETRY_BUTTON}
/>
>
<Button.Icon src={icons.ArrowCircleClockwise} />
<Button.Text>{translate('attachmentView.retry')}</Button.Text>
</Button>
</View>
);
}
Expand Down
14 changes: 8 additions & 6 deletions src/components/Domain/CopyableTextField.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ActivityIndicator from '@components/ActivityIndicator';
import Button from '@components/Button';
import Button from '@components/ButtonComposed';
import CopyTextToClipboard from '@components/CopyTextToClipboard';
import Text from '@components/Text';

Expand All @@ -10,6 +10,8 @@ import useThemeStyles from '@hooks/useThemeStyles';

import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';

import CONST from '@src/CONST';

import type {StyleProp, TextStyle, ViewStyle} from 'react-native';

import React, {useState} from 'react';
Expand Down Expand Up @@ -71,12 +73,12 @@ function CopyableTextField({value, isLoading = false, style, textStyle, shouldDi
</View>
{shouldDisplayShowMoreButton && (
<Button
small
text={translate(expanded ? 'common.showLess' : 'common.showMore')}
size={CONST.BUTTON_SIZE.SMALL}
onPress={() => setExpanded((current) => !current)}
shouldShowRightIcon
iconRight={expanded ? icons.UpArrow : icons.DownArrow}
/>
>
<Button.Text>{translate(expanded ? 'common.showLess' : 'common.showMore')}</Button.Text>
<Button.Icon src={expanded ? icons.UpArrow : icons.DownArrow} />
</Button>
)}
</>
)}
Expand Down
12 changes: 8 additions & 4 deletions src/components/MapView/GPSMapView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Button from '@components/Button';
import Button from '@components/ButtonComposed';
import ImageSVG from '@components/ImageSVG';

import useAppFocusEvent from '@hooks/useAppFocusEvent';
Expand Down Expand Up @@ -319,10 +319,14 @@ function GPSMapView({accessToken, style, mapPadding, styleURL, pitchEnabled, way
<View style={[styles.pAbsolute, styles.p5, styles.t0, styles.r0, styles.zIndex1]}>
<Button
onPress={centerMap}
iconFill={theme.icon}
icon={expensifyIcons.Crosshair}
accessibilityLabel={translate('common.center')}
/>
>
<Button.Icon
src={expensifyIcons.Crosshair}
fill={theme.icon}
hoverFill={theme.icon}
/>
</Button>
</View>
</View>
) : (
Expand Down
12 changes: 8 additions & 4 deletions src/components/MapView/MapView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Button from '@components/Button';
import Button from '@components/ButtonComposed';
import ImageSVG from '@components/ImageSVG';
import Text from '@components/Text';

Expand Down Expand Up @@ -374,10 +374,14 @@ function MapView({
<View style={[styles.pAbsolute, styles.p5, styles.t0, styles.r0, styles.zIndex1]}>
<Button
onPress={centerMap}
iconFill={theme.icon}
icon={expensifyIcons.Crosshair}
accessibilityLabel={translate('common.center')}
/>
>
<Button.Icon
src={expensifyIcons.Crosshair}
fill={theme.icon}
hoverFill={theme.icon}
/>
</Button>
</View>
)}
</View>
Expand Down
12 changes: 8 additions & 4 deletions src/components/MapView/MapViewImpl.web.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Button from '@components/Button';
import Button from '@components/ButtonComposed';

import 'mapbox-gl/dist/mapbox-gl.css';
import ImageSVG from '@components/ImageSVG';
Expand Down Expand Up @@ -335,10 +335,14 @@ function MapViewImpl({
<View style={[styles.pAbsolute, styles.p5, styles.t0, styles.r0, styles.zIndex1]}>
<Button
onPress={centerMap}
iconFill={theme.icon}
icon={expensifyIcons.Crosshair}
accessibilityLabel={translate('common.center')}
/>
>
<Button.Icon
src={expensifyIcons.Crosshair}
fill={theme.icon}
hoverFill={theme.icon}
/>
</Button>
</View>
)}
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ function SubmitPrimaryActionContent({reportID}: SubmitPrimaryActionProps) {

return (
<AnimatedSubmitButton
success
variant={CONST.BUTTON_VARIANT.SUCCESS}
text={shouldUseMarkAsDoneCopy ? translate('common.markAsDone') : translate('common.submit')}
isMarkAsDone={shouldUseMarkAsDoneCopy}
onPress={() => handleSubmit()}
Expand Down
8 changes: 5 additions & 3 deletions src/components/ReportActionItem/ChronosOOOListActions.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Button from '@components/Button';
import Button from '@components/ButtonComposed';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import Text from '@components/Text';

Expand All @@ -10,7 +10,7 @@ import {getOriginalMessage} from '@libs/ReportActionsUtils';

import {removeEvent} from '@userActions/Chronos';

import type CONST from '@src/CONST';
import CONST from '@src/CONST';
import type ReportAction from '@src/types/onyx/ReportAction';

import React from 'react';
Expand Down Expand Up @@ -61,8 +61,10 @@ function ChronosOOOListActions({reportID, action}: ChronosOOOListActionsProps) {
)}
</Text>
<Button
small
size={CONST.BUTTON_SIZE.SMALL}
style={styles.pl2}
// Restores the 12px horizontal padding from the legacy implementation.
innerStyles={styles.ph3}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as in CarouselItem, please add the one line comment explaining that ph3 replaces the ph1 that ButtonText would normally contribute.

onPress={() => removeEvent(reportID, action.reportActionID, event.id, events)}
>
<Text style={styles.buttonSmallText}>{translate('common.remove')}</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function SubmitActionButtonContent() {

return (
<AnimatedSubmitButton
success
variant={CONST.BUTTON_VARIANT.SUCCESS}
text={shouldUseMarkAsDoneCopy ? translate('common.markAsDone') : translate('common.submit')}
isMarkAsDone={shouldUseMarkAsDoneCopy}
onPress={handleSubmit}
Expand Down
11 changes: 6 additions & 5 deletions src/components/Search/SearchPageHeader/SearchSaveButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Button from '@components/Button';
import Button from '@components/ButtonComposed';
import Icon from '@components/Icon';
import {PressableWithFeedback} from '@components/Pressable';

Expand Down Expand Up @@ -51,12 +51,13 @@ function SearchSaveButton() {

return (
<Button
small
icon={expensifyIcons.Bookmark}
text={translate('common.save')}
size={CONST.BUTTON_SIZE.SMALL}
onPress={openSaveSearchPage}
sentryLabel={CONST.SENTRY_LABEL.SEARCH.FILTER_SAVE_BUTTON}
/>
>
<Button.Icon src={expensifyIcons.Bookmark} />
<Button.Text>{translate('common.save')}</Button.Text>
</Button>
);
}

Expand Down
Loading
Loading