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

[Refactor] Add getButtonStyles function to the Button component #3993

Closed
mountiny opened this issue Jul 12, 2021 · 7 comments
Closed

[Refactor] Add getButtonStyles function to the Button component #3993

mountiny opened this issue Jul 12, 2021 · 7 comments
Assignees

Comments

@mountiny
Copy link
Contributor

mountiny commented Jul 12, 2021

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

This is a refactoring issue. No actions in UI involved.

As raised here by @marcaaron, the Button component has got more props over time which influence the styling of the Button. The inline ternaries are hard to follow and it is easy to get lost in them.

https://github.com/Expensify/Expensify.cash/blob/de03a02ecd2bd95e10b5aab50f3abadc8bb854a5/src/components/Button.js#L108-L127

Similarly the ternaries are used for the Text styles too:

https://github.com/Expensify/Expensify.cash/blob/de03a02ecd2bd95e10b5aab50f3abadc8bb854a5/src/components/Button.js#L84-L96

Expected Result:

We would like to refactor the Button component so we create separate functions to determine style of the OpacityView and Text: getButtonStyles(hovered, disabled, small, large, success, danger, shouldRemoveRightBorderRadius, shouldRemoveLeftBorderRadius, ...etc) and getTextStyle(small, large, success, danger, ...etc).

That will improve readability and maintainability as we will most likely need to add new props as the app development will continue.

Then we can either call the getButtonStyles function similarly as we get the additionalStyles here: https://github.com/Expensify/Expensify.cash/blob/de03a02ecd2bd95e10b5aab50f3abadc8bb854a5/src/components/Button.js#L72

Or we can call the getButtonStyles function inline in the OpacityView tag such that style={getButtonStyles(params)}

Same goes for the getTextStyles.

Actual Result:

Goals described above.

Workaround:

No workaround

Platform:

Where is this issue occurring?

Web ✔️
iOS ✔️
Android ✔️
Desktop App ✔️
Mobile Web ✔️

Version Number:
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Expensify/Expensify Issue URL:

View all open jobs on Upwork

@mountiny mountiny added the AutoAssignerTriage Auto assign issues for triage to an available triage team member label Jul 12, 2021
@MelvinBot
Copy link

Triggered auto assignment to @mateocole (AutoAssignerTriage), see https://stackoverflow.com/c/expensify/questions/4749 for more details.

@MelvinBot MelvinBot removed the AutoAssignerTriage Auto assign issues for triage to an available triage team member label Jul 12, 2021
@mountiny mountiny added the AutoAssignerTriage Auto assign issues for triage to an available triage team member label Aug 6, 2021
@MelvinBot
Copy link

Triggered auto assignment to @laurenreidexpensify (AutoAssignerTriage), see https://stackoverflow.com/c/expensify/questions/4749 for more details.

@MelvinBot MelvinBot added Daily KSv2 Overdue and removed AutoAssignerTriage Auto assign issues for triage to an available triage team member labels Aug 6, 2021
@laurenreidexpensify
Copy link
Contributor

swamped on allocations - can someone else triage this for me today? thanks

@MelvinBot MelvinBot removed the Overdue label Aug 9, 2021
@laurenreidexpensify laurenreidexpensify removed their assignment Aug 9, 2021
@laurenreidexpensify laurenreidexpensify added the AutoAssignerTriage Auto assign issues for triage to an available triage team member label Aug 9, 2021
@MelvinBot
Copy link

Triggered auto assignment to @jboniface (AutoAssignerTriage), see https://stackoverflow.com/c/expensify/questions/4749 for more details.

@MelvinBot MelvinBot removed the AutoAssignerTriage Auto assign issues for triage to an available triage team member label Aug 9, 2021
@MelvinBot
Copy link

Triggered auto assignment to @joelbettner (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@jboniface
Copy link

i can't really assess this issue, moving it to engineering for triage

@marcaaron
Copy link
Contributor

I agree this would be nice to do, but seems kind of low priority and has already been sitting for 28 days. Just going to close it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants