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
LeadingIcon
- passing svg
prop as string
results in unexpected SVG styling
#2779
Comments
Hey Byron, |
I would suggest to not use the On another note, if you want to preserve the SVG as-is, why not loading the SVG directly as a React component? The MC tooling already allows that if the file name ends with Thanks |
Hey @ddouglasz, thanks for responding. I was the person who originally implemented the One thing I'd like to point out is that expecting an SVG as a string is a bit of an awkward pattern, and goes against current best practices for handling SVG assets in merchant center applications (which is to build them as react components with the Perhaps it would make sense for the |
@emmenko I'm just fine with passing a react component, the api/props and how they are handled in I can put in a PR to implement the change if that's alright with everyone. |
I just want to make sure that we don't change anything related to I honestly don't know much about the |
I think the idea behind the We should be using the |
@CarlosCortizasCT the issue with that is that the As an example, you can see the icon in this card on the welcome page as it is currently: |
Hi @ByronDWall I'm sorry but I'm struggling to understand this sentence:
The way I see it, all icons should be rendered the same not matter whether they are part of ui-kit or not. We (commercetools) should aim for visual consistency and we would breaking that if different icons have, for instance, different paddings. Perhaps I'm mistaken here and we can maybe have a meeting with @FilPob to discuss this further and better understand, at least from my side, the reasoning behind this requirement. Would that work for you? |
hey @CarlosCortizasCT that works for me. I am happy to discuss this with you and Filip. Our team is having our onsite meeting this week, so my availability is very limited until Friday. I'm sure we can come to a reasonable decision either asynchronously during the week or in a quick meeting Friday. Thanks! |
Hi @ByronDWall @FilPob and I had a discussion about this issue and know I understand better what the problem is. Now that I have a better understanding though, I'm hesitant about the
The way I understand this component is to have a themed icon in order to increase visual attention by using prominent colors but the way custom icons are being used does not fall into path as they need to have their own colors and a transparent background. The only parts both use cases share is the size and the border (although the latter is only try for one All that leads me to think whether having custom SVGs actually make sense in the I think the idea with custom icons is that we want to allow any kind of icons but we want them to share the sizes range and the border so I believe it would make more sense to have something like a @FilPob @ByronDWall what do you about this proposal? |
@CarlosCortizasCT thanks for the explanation. I agree with the approach of the new component. Just two things to clarify
Should the new |
This would be the components API: type TCustomIconProps = {
size?: 'small' | 'medium' | 'big' | 'scale'; // <--- Same as our icons
}; The component will render the provided icon with the selected size and with a rounded border with no paddings. I think what we're trying to cover is for icons that are required in specific use cases, to have a consistent size. To be honest, the border thing should also be optional from my point of view because it will depend on the specific icon used, but maybe you have more context here and it's better to always use it. |
okay then I misunderstand it before. I agree that the +1 to making the border optional regarding the size: For Byron's use case, we would need that |
Thanks @FilPob That depends on what you think the custom icons should look like in terms of the size. If we want for them to have the same size options as the |
Ah okay right we could reuse the sizes of the |
Please @ByronDWall, can you confirm this new component would be enough for your use case? |
@FilPob @CarlosCortizasCT Hey, sorry I missed this conversation until now. I think that having a separate Overall, I think the proposed component api makes a lot of sense, I just want to recap so I am sure I'm not missing anything:
Does this sound right? |
Yes, those would be the requirements. We can also discuss if we would need to support inline SVGs on top of |
@CarlosCortizasCT would you like to remove support for inline SVG's from |
That's something we can also do as a follow-up, but that's technically a breaking change so I wouldn't get into that for now. |
works for me, thanks! |
@ByronDWall would it be ok to close this issue since we already implemented the new CustomIcon component? 🤔 |
@CarlosCortizasCT I think so, thanks! |
Describe the bug
The
LeadingIcon
component API currently accepts ansvg
prop, which is currently astring
that is rendered internally by theInlineSVG
component.The intention behind allowing for an
svg
prop as well as anicon
prop is so that theLeadingIcon
can display "custom" SVG's.The
InlineSVG
component sets allfill
values within the SVG tofill: inherit
by default in this style method which means that all elements of the SVG are rendered in a single color.This means that custom SVG's displayed by
LeadingIcon
will always have a single color, which leads to unexpected results when passing in SVG's that have multiple fill colors.To Reproduce
Steps to reproduce the behavior:
LeadingIcon
into a filefill
values as a stringLeadingIcon
component viasvg
propLeadingIcon
displays an svg with only onefill
colorExpected behavior
SVG's passed to
LeadingIcon
are displayed with all declared fill colors.Screenshots
Screen.Recording.2024-04-11.at.1.36.17.PM.mov
Additional context
Being able to display custom SVG's as-expected in
LeadingIcon
is one of the main use-cases our team needs to be able to achieve with this component, so I would like to suggest a couple of solutions that the first contact team could implement relatively quickly:remove the
*:not([fill='none'])
selector from SVG's built by theInlineSVG
component for SVG's rendered byLeadingIcon
accept a
ReactComponent
instead of astring
for theLeadingIcon
svg
prop.The text was updated successfully, but these errors were encountered: