-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Comments
Triggered auto assignment to @mateocole ( |
Triggered auto assignment to @laurenreidexpensify ( |
swamped on allocations - can someone else triage this for me today? thanks |
Triggered auto assignment to @jboniface ( |
Triggered auto assignment to @joelbettner ( |
i can't really assess this issue, moving it to engineering for triage |
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. |
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 theOpacityView
andText
:getButtonStyles(hovered, disabled, small, large, success, danger, shouldRemoveRightBorderRadius, shouldRemoveLeftBorderRadius, ...etc)
andgetTextStyle(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 theadditionalStyles
here: https://github.com/Expensify/Expensify.cash/blob/de03a02ecd2bd95e10b5aab50f3abadc8bb854a5/src/components/Button.js#L72Or we can call the
getButtonStyles
function inline in theOpacityView
tag such thatstyle={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
The text was updated successfully, but these errors were encountered: