-
Notifications
You must be signed in to change notification settings - Fork 985
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
Clear icon is tinted incorrectly #15606
Comments
I talked to @pedro-et last week about this issue and he suggested we use SVGs for icons, instead of PNGs. Although the issue I reported can be solved by asking designers to update the clear icon to have an I also think icons should be SVGs, but I'm probably missing something. @flexsurfer, @Parveshdhull, @brianfernalld, @OmarBasem do you know the primary reason for icons to be PNGs instead of SVGs? Have you perhaps found rendering issues? Performance issues maybe? Although we can easily memoize SVG icons and any performance hit should be nullified. Edit: For reference, the code below is a working example where we can control the foreground and background color of the clear icon. (defn clear-icon
[{:keys [size fg-color bg-color]
:or {size 20}}]
[svg/svg
{:width size
:height size
:view-box (str "0 0 " size " " size)
:fill :none}
[svg/path
{:d
"M3 10C3 6.13401 6.13401 3 10 3C13.866 3 17 6.13401 17 10C17 13.866 13.866 17 10 17C6.13401 17 3 13.866 3 10Z"
:fill bg-color}]
[svg/path
{:d
"M9.15142 9.99998L7.07566 12.0757L7.9242 12.9243L9.99994 10.8485L12.0757 12.9242L12.9242 12.0757L10.8485 9.99998L12.9242 7.92421L12.0757 7.07568L9.99994 9.15145L7.92421 7.07572L7.07568 7.92425L9.15142 9.99998Z"
:fill fg-color}]]) |
Also, SVGs can be scaled with no compromise on quality. This means we won't need duplicated icons (x2, x3). And they have smaller file sizes compared to PNGs. I am not sure if there is a specific reason we are using PNGs. |
@flexsurfer, since you have more context of past decisions in status-mobile, do you know why it was decided to use PNGs for icons instead of SVGs? I'm strongly inclined to create a PR that migrates all icons to SVGs. In web development, using SVGs for icons is a no-brainer, but perhaps there's something I'm missing in RN. Could you please, share your opinion? FYI The issue's description and my comment #15606 (comment) above are important to understand the problem. Thank you :) |
back then we had 2 problems, performance and lack of good implementation, it didn't work well for all different svgs and for all devices and then implemented the macro for colors but then we had more complex svg, and they were exported differently by tools and didn't work well, so we had to tune them manually in any way it was slow and buggy so if we can solve this just by asking designers to change the icon in figma, this is the way to go |
hm, actually you say we still have to do something additional in the code to make it looks right, so probably we could use svg in that case for some "special" icons , wdyt? in that case we could have them as reagent components right ? |
Thanks for all the context way back to 2017!
Correct, that would work @flexsurfer. But we'll have a bunch of exceptions, like Nowadays we have Figma and as far as I tested the SVG exported by Figma is quite clean and can be adapted to hiccup, and they rendered correctly. Of course, there are many icons I haven't tested, so take my experiment with a grain of salt. So the ideal approach to me would be to have a single solution to all icons, not a mix of PNGs and SVGs, but let's do a mix for now and see how it goes. I agree with your suggestion, it's also less risky than changing a bunch of stuff and introducing issues in some devices, who knows. If, in the future, we feel using SVGs is the way to go we can gradually migrate the other icons anyway. Thanks @flexsurfer, I'll try to fix only for the clear icon using an SVG for now. |
This commit solves the problem described in detail in issue #15606, but in essence, it fixes the clear icon by integrating rudimentary support for SVG icons. Fixes #15606 - Hopefully, if SVG icons prove to be a solid solution, we can easily and progressively migrate PNG icons to SVGs, but for the moment, it was aligned with @flexsurfer #15606 (comment) that we'll only use SVG icons on demand. - Note that it's possible to import SVGs directly via js/require by installing the library react-native-svg-transformer, but this approach is only good when we don't want/need color customization, which is rarely the case with icons where we want to change the foreground and/or background colors. I opted for rendering the SVG icon as hiccup to support color customization. - Since icons are fully memoized, the app's performance is on the same ballpark as PNGs rendered with RN Image. - It's possible to trim down SVGs by using a tool such as https://github.com/svg/svgo, but this is obviously outside the scope of this PR.
This commit solves the problem described in detail in issue #15606, but in essence, it fixes the clear icon by integrating rudimentary support for SVG icons. Fixes #15606 - Hopefully, if SVG icons prove to be a solid solution, we can easily and progressively migrate PNG icons to SVGs, but for the moment, it was aligned with @flexsurfer #15606 (comment) that we'll only use SVG icons on demand. - Note that it's possible to import SVGs directly via js/require by installing the library react-native-svg-transformer, but this approach is only good when we don't want/need color customization, which is rarely the case with icons where we want to change the foreground and/or background colors. I opted for rendering the SVG icon as hiccup to support color customization. - Since icons are fully memoized, the app's performance is on the same ballpark as PNGs rendered with RN Image. - It's possible to trim down SVGs by using a tool such as https://github.com/svg/svgo, but this is obviously outside the scope of this PR.
Bug Report
The
clear
icon is currently exported from Figma with theX
in the center using white pixels. The problem is that in order to programmatically color icons, we need to use thetintColor
prop of the RNImage
component, but the prop works by tinting non-transparent pixels. Because theX
is not transparent, any tint color will make the component look like a simple circle.Note: I haven't looked at other icons and if they could have the same issue.
Solution
Bring the topic to designers' attention and align with the dev team the best approach.
Resources
Figma Iconset https://www.figma.com/file/qLLuMLfpGxK9OfpIavwsmK/Iconset?node-id=3239-987&t=sUSeh1WzRnxzYj3q-0
The text was updated successfully, but these errors were encountered: