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

feat: add iconPosition to FAB #4436

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

caiotracera
Copy link

@caiotracera caiotracera commented Jun 17, 2024

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 the label respectively in this order. But we may want to render the label before the icon, and that is not possible at this moment. Because of that, this PR adds a new prop called iconPosition (we can change it if necessary) that will change the flex-direction prop based on the value:

  • When the iconPosition is left, the flex-direction will be set to row (the current default value);
  • When the iconPosition is right, the flex-direction will be set to row-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

  • Open the example app;
  • Navigate to the Floating Action Button examples;
  • You will find the example that I added with the two possible values for this prop;

CleanShot 2024-06-17 at 15 48 35@2x

But you can easily test on your own by simply adding the iconPosition prop to the FAB component. The left is the default value, so:

  • If the iconPosition is not defined, it will assume the left value and stay as it is today.
  • If the iconPosition is set to right, the label and the icon should change places.
  • If the iconPosition is set but no label is provided, the flex-direction will be changed to row-inverted but it should not impact on the final result.

@callstack-bot
Copy link

callstack-bot commented Jun 17, 2024

Hey @caiotracera, thank you for your pull request 🤗. The documentation from this branch can be viewed here.

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.

None yet

2 participants