Skip to content

[22658] Highlight specified cancel buttons #23464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 26, 2023
5 changes: 5 additions & 0 deletions src/components/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ const propTypes = {
// eslint-disable-next-line react/forbid-prop-types
textStyles: PropTypes.arrayOf(PropTypes.object),

/** Whether we should use the default theme color */
default: PropTypes.bool,

/** Whether we should use the success theme color */
success: PropTypes.bool,

Expand Down Expand Up @@ -142,6 +145,7 @@ const defaultProps = {
style: [],
innerStyles: [],
textStyles: [],
default: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to specify props for the default style if it's only affecting the hover style. We can replace this with shouldShowDefaultHoverEffect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried to keep it consistent with success and danger styles. Each button may be only 1 of success, danger, default. Would you say shouldShowDefaultHoverEffect is better?

Copy link
Contributor

Choose a reason for hiding this comment

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

The button has a default style applied, so adding new props default just for the hovered seems confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated it to shouldHaveHoverEffect

success: false,
danger: false,
children: null,
Expand Down Expand Up @@ -295,6 +299,7 @@ class Button extends Component {
...this.props.innerStyles,
]}
hoverStyle={[
this.props.default && !this.props.isDisabled ? styles.buttonDefaultHovered : undefined,
this.props.success && !this.props.isDisabled ? styles.buttonSuccessHovered : undefined,
this.props.danger && !this.props.isDisabled ? styles.buttonDangerHovered : undefined,
]}
Expand Down
5 changes: 5 additions & 0 deletions src/components/ConfirmContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ const propTypes = {
/** Whether we should show the cancel button */
shouldShowCancelButton: PropTypes.bool,

/** Whether the cancel button has hover effect */
cancelWithHoverEffect: PropTypes.bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/Expensify/App/blob/main/contributingGuides/STYLE.md#boolean-variables-and-props

Boolean props or variables must be prefixed with should or is to make it clear that they are Boolean. Use should when we are enabling or disabling some features and is in most other cases.

We should change this with the should prefix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to shouldCancelBtnHaveHoverEffect


/** Styles for view */
// eslint-disable-next-line react/forbid-prop-types
contentStyles: PropTypes.arrayOf(PropTypes.object),
Expand All @@ -51,6 +54,7 @@ const defaultProps = {
danger: false,
onCancel: () => {},
shouldShowCancelButton: true,
cancelWithHoverEffect: false,
contentStyles: [],
};

Expand All @@ -76,6 +80,7 @@ function ConfirmContent(props) {
style={[styles.mt3, styles.noSelect]}
onPress={props.onCancel}
text={props.cancelText || props.translate('common.no')}
default={props.cancelWithHoverEffect}
/>
)}
</View>
Expand Down
5 changes: 5 additions & 0 deletions src/components/ConfirmModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ const propTypes = {
/** Whether we should show the cancel button */
shouldShowCancelButton: PropTypes.bool,

/** Whether the cancel button has hover effect */
cancelWithHoverEffect: PropTypes.bool,

/** Callback method fired when the modal is hidden */
onModalHide: PropTypes.func,

Expand All @@ -53,6 +56,7 @@ const defaultProps = {
danger: false,
onCancel: () => {},
shouldShowCancelButton: true,
cancelWithHoverEffect: false,
shouldSetModalVisibility: true,
title: '',
onModalHide: () => {},
Expand Down Expand Up @@ -80,6 +84,7 @@ function ConfirmModal(props) {
success={props.success}
danger={props.danger}
shouldShowCancelButton={props.shouldShowCancelButton}
cancelWithHoverEffect={props.cancelWithHoverEffect}
/>
</Modal>
);
Expand Down
2 changes: 2 additions & 0 deletions src/pages/workspace/WorkspaceInitialPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ function WorkspaceInitialPage(props) {
confirmText={props.translate('workspace.bankAccount.updateToUSD')}
cancelText={props.translate('common.cancel')}
danger
cancelWithHoverEffect
/>
<ConfirmModal
title={props.translate('workspace.common.delete')}
Expand All @@ -280,6 +281,7 @@ function WorkspaceInitialPage(props) {
confirmText={props.translate('common.delete')}
cancelText={props.translate('common.cancel')}
danger
cancelWithHoverEffect
/>
</FullPageNotFoundView>
)}
Expand Down
1 change: 1 addition & 0 deletions src/pages/workspace/WorkspaceMembersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ function WorkspaceMembersPage(props) {
/>
<ConfirmModal
danger
cancelWithHoverEffect
title={props.translate('workspace.people.removeMembersTitle')}
isVisible={removeMembersConfirmModalVisible}
onConfirm={removeUsers}
Expand Down
5 changes: 5 additions & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,11 @@ const styles = {
textAlign: 'center',
},

buttonDefaultHovered: {
backgroundColor: themeColors.buttonHoveredBG,
borderWidth: 0,
},

buttonSuccess: {
backgroundColor: themeColors.success,
borderWidth: 0,
Expand Down