-
-
Notifications
You must be signed in to change notification settings - Fork 425
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
style support react-native #245
Comments
Hello @7ynk3r, I thought SVGO was doing something like that but probably not completely. We will not work on a script to inline style converter in svgr. But since it is based on Babel, you can try to create your own plugin to do it. Right now I don’t have any solution for you, except the write of a new Babel plugin. See https://www.smooth-code.com/open-source/svgr/docs/custom-transformations/ for more information. |
If anyone reach this place, there's a simple solution to this problem. You have to optimize your svg files using https://github.com/svg/svgo and the following config file
This will convert styles into inline attributes. |
@7ynk3r since svgr is using svgo under the hood, it should work if you specify this config in your |
Thanks for the insight @neoziro ! Use {
"svgoConfig": {
"plugins": [
{
"inlineStyles": {
"onlyMatchedOnce": false
}
}
]
}
} |
🐛 Bug Report
I'm converting a SVG (with styles) into a react-native component. In the transformation the styles get lost and it makes sense (in some sense) given that
react-native-svg
doesn't have a tag forstyle
.What is the best course of action here? Is it possible to make
svgr
de-style the SVG before converting it? I don't want designer having to alter their work before providing it to devs.To Reproduce
Expected behavior
Colors are lost (and any other style).
Link to repl or repo (highly encouraged)
Copy the SVG and paste it into the playground, make sure to export to react-native.
https://www.smooth-code.com/open-source/svgr/playground/
The text was updated successfully, but these errors were encountered: