feat: add iconPosition to FAB#4436
Closed
caiotracera wants to merge 5 commits intocallstack:mainfrom
Closed
Conversation
|
Hey @caiotracera, thank you for your pull request 🤗. The documentation from this branch can be viewed here. |
1062366 to
1da5d15
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
When using the
Floating Action Buttoncomponent, we are able to provide the icon and the label that we want to use. But, searching between the documentation and the code, it seems that there are no implemented way of changing the order the label and the icon are displayed.By default, we render the
iconand thelabelrespectively in this order. But we may want to render thelabelbefore theicon, and that is not possible at this moment. Because of that, this PR adds a new prop callediconPosition(we can change it if necessary) that will change theflex-directionprop based on the value:iconPositionisleft, theflex-directionwill be set torow(the current default value);iconPositionisright, theflex-directionwill be set torow-inverted;Related issue
I didn't find any issues about this, but I need to implement a solution that will use the FAB component, but the UX Designer wants the icon to be rendered on the right of the label. I did try to fix this on my side, but I thought that it would be a good idea to have this option by default, because other developers may also want to change the display order.
Test plan
exampleapp;Floating Action Buttonexamples;But you can easily test on your own by simply adding the
iconPositionprop to theFABcomponent. Theleftis the default value, so:iconPositionis not defined, it will assume theleftvalue and stay as it is today.iconPositionis set toright, the label and the icon should change places.iconPositionis set but nolabelis provided, theflex-directionwill be changed torow-invertedbut it should not impact on the final result.