Skip to content
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

Standardize Button Usages #2878

Merged
merged 7 commits into from
May 19, 2021
Merged

Standardize Button Usages #2878

merged 7 commits into from
May 19, 2021

Conversation

marcaaron
Copy link
Contributor

@marcaaron marcaaron commented May 13, 2021

Details

cc @shawnborton This is a refactor of most of our "button" usages so they will use a common Button component to replace the ButtonWithLoader that is pretty underutilized and leads to a lot of duplicate JSX and some style inconsistencies e.g. only certain buttons react to hover styles on web.

Fixed Issues

Fixes https://github.com/Expensify/Expensify/issues/164118

Tests

QA Steps

  1. No specific QA, just test various button usages for regressions or any weirdness.

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

2021-05-14_13-01-23

Including screenshots to verify the button still works, the only change is that buttons will respond to hover on web and very slight change to the animation - since we are no longer using a TouchableOpacity for many buttons.

Web

2021-05-14_13-07-38

Mobile Web

2021-05-14_13-08-40

Desktop

2021-05-14_13-09-44

iOS

2021-05-14_13-18-04

Android

2021-05-14_14-25-48

@marcaaron marcaaron self-assigned this May 13, 2021
@marcaaron marcaaron changed the title [WIP] Standardize Button Usages Standardize Button Usages May 15, 2021
@marcaaron marcaaron marked this pull request as ready for review May 15, 2021 00:50
@marcaaron marcaaron requested a review from a team as a code owner May 15, 2021 00:50
@marcaaron marcaaron requested a review from shawnborton May 15, 2021 00:50
@MelvinBot MelvinBot requested review from joelbettner and deetergp and removed request for a team May 15, 2021 00:51
@shawnborton
Copy link
Contributor

This is great. Curious what you would do for this kind of button where it has an icon, and the icon is in front of the text string:
image

shawnborton
shawnborton previously approved these changes May 17, 2021
@marcaaron
Copy link
Contributor Author

Curious what you would do for this kind of button where it has an icon, and the icon is in front of the text string

The approach I went with for now would be to pass in the "button content" as a prop.

https://github.com/Expensify/Expensify.cash/blob/b079af398ee5551388d165d6a736686fbd955346/src/pages/settings/Profile/ProfilePage.js#L274-L287

That would effectively make it so a button's content could be "anything".

However, if that's too much flexibility we could embed the icon into a button as an option and then enable it with a boolean prop flag like shouldShowDownCaret. I sorta feel like the decision to add props like that should depend on how many usages of this button style we have.

@shawnborton
Copy link
Contributor

I sorta feel like the decision to add props like that should depend on how many usages of this button style we have.

Totally agree with that, all of this sounds good to me.

};

const ButtonWithLoader = props => (
<TouchableOpacity
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 seee TouchableOpacity used anywhere in the new Button.js component (I could be missing it). Is there a TouchableOpacity.js file that could be deleted just like this ButtonWithLoader.js file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, nope because this component is built into react-native.

joelbettner
joelbettner previously approved these changes May 18, 2021
Copy link
Contributor

@joelbettner joelbettner left a comment

Choose a reason for hiding this comment

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

Looks like a merge conflict cropped up in one of the files. :(

Other than that, it looks good to me.

@marcaaron marcaaron dismissed stale reviews from joelbettner and shawnborton via d6fb1f9 May 18, 2021 19:19
@marcaaron
Copy link
Contributor Author

I'll look into why these tests are failing in a sec. Probably someone added a ButtonWithLoader

@marcaaron
Copy link
Contributor Author

It was me, I added it lol

Copy link
Contributor

@deetergp deetergp left a comment

Choose a reason for hiding this comment

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

Looks pretty straight forward to me.

@marcaaron
Copy link
Contributor Author

Gonna merge this to prevent conflicts.

@marcaaron marcaaron merged commit 8565f48 into main May 19, 2021
@marcaaron marcaaron deleted the marcaaron-rComponent branch May 19, 2021 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants