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: Icon parent wrapper element/component #720

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

bombillazo
Copy link
Contributor

@bombillazo bombillazo commented Apr 20, 2023

Resolves #719

  • Add a feature to auto-wrap icons in a span component with a class name

@bombillazo bombillazo changed the title Icon parent wrapper element/component FEAT: Icon parent wrapper element/component Apr 20, 2023
@bombillazo
Copy link
Contributor Author

Hey @kamijin-fanta , anyone could take a look at this PR?

@bombillazo
Copy link
Contributor Author

Any takers? @kamijin-fanta @gorangajic @nolanleung

@kamijin-fanta
Copy link
Member

It is unclear if a merge should be performed because the use case is not known. You could write code <span className="wrapper"><FaSearch /></span>. You can also define such a wrapper component.

@bombillazo
Copy link
Contributor Author

Hey, imagine the case where we wish to apply a custom styling/wrapper to every icon class we import to control their global behavior. How would one currently apply such a wrapper to all icons? Must one create the custom class or wrapper component on every icon instance component used in the code?

That is what this PR tries to address, by incorporating the logic into the icons and context one can globally control the icons.

@kamijin-fanta
Copy link
Member

There is still the ability to globally assign class names. Whether it is necessary to wrap components depends on the situation in which they will be used. I would like to know in what cases it is necessary to wrap repeatedly.

@bombillazo
Copy link
Contributor Author

bombillazo commented Jun 1, 2023

For UI purposes, we want to wrap any and all react icons we import from react-icon inside a <span /> tag. This is due to us using an existing UI framework that already wraps its own icons in <span /> and applies styling to those via CSS matching span.class-name.

Imagine I use the <FaSearch /> icon in 5 different components. We would need to update every single usage to add a <span /> tag. And that is just 1 icon; we are using dozens of icons in different components and layouts.

@kamijin-fanta
Copy link
Member

Think of it as difficult to add features that are not used very often. If such UI frameworks are used a lot in the React community, I would welcome them. However, when merging, the API should accept generic React components, not just span.

@bombillazo
Copy link
Contributor Author

I can agree with that, I will fix to make the wrapper component generic. 👍

@bombillazo
Copy link
Contributor Author

Hey @kamijin-fanta, I updated the functionality; please review it to see if it looks better.

component dynamically and assign className
@bombillazo
Copy link
Contributor Author

Hey @kamijin-fanta , the new implementation aligns to using generic React components rather than hardcode the wrapper to span.

@bombillazo
Copy link
Contributor Author

Hey @kamijin-fanta , any feedback?

@bombillazo
Copy link
Contributor Author

Hey @kamijin-fanta , any update on if this feature can be merged?

@kamijin-fanta
Copy link
Member

If anyone else needs it, please let me know the use case. I will not add a feature that only one person needs.

@bombillazo
Copy link
Contributor Author

Fair enough, I'll leave it open in case, we've made it work for use using patch-package and it is working perfectly so far.

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

Successfully merging this pull request may close these issues.

[Feature]: Icon parent wrapper element/component
2 participants