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 Button
component, 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
icon
and thelabel
respectively in this order. But we may want to render thelabel
before 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-direction
prop based on the value:iconPosition
isleft
, theflex-direction
will be set torow
(the current default value);iconPosition
isright
, theflex-direction
will 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
example
app;Floating Action Button
examples;But you can easily test on your own by simply adding the
iconPosition
prop to theFAB
component. Theleft
is the default value, so:iconPosition
is not defined, it will assume theleft
value and stay as it is today.iconPosition
is set toright
, the label and the icon should change places.iconPosition
is set but nolabel
is provided, theflex-direction
will be changed torow-inverted
but it should not impact on the final result.