Override createElement to map svg elements to react-native-svg ones#11129
Override createElement to map svg elements to react-native-svg ones#11129
createElement to map svg elements to react-native-svg ones#11129Conversation
| description: __( 'Add text that respects your spacing and tabs -- perfect for displaying code.' ), | ||
|
|
||
| icon: <SVG viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><Path d="M0,0h24v24H0V0z" fill="none" /><Path d="M9.4,16.6L4.8,12l4.6-4.6L8,6l-6,6l6,6L9.4,16.6z M14.6,16.6l4.6-4.6l-4.6-4.6L16,6l6,6l-6,6L14.6,16.6z" /></SVG>, | ||
| icon: <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M0,0h24v24H0V0z" fill="none" /><path d="M9.4,16.6L4.8,12l4.6-4.6L8,6l-6,6l6,6L9.4,16.6z M14.6,16.6l4.6-4.6l-4.6-4.6L16,6l6,6l-6,6L14.6,16.6z" /></svg>, |
There was a problem hiding this comment.
Not sure about path, g and rest, but at least SVG needs to stay as it adds some accessibility features behind the scenes. It's expected to have it everywhere.
There was a problem hiding this comment.
Couldn't we just map svg to our SVG then (instead of the one from react-native-svg`)?
|
Did you make it work? Changes in both PRs look reasonable. I will try to test it on Friday. |
|
It works, but still needs some cleanup on the mobile PR (around how we import/build modules). |
|
Let me know when it is fully working, I will ping a few more developers to look closer into it. The solution we have at the moment helped us to move forward, but I'm still not 100% confident it's bulletproof in the long run. Having this Eslint rule: |
|
@Tug do you plan to continue working on this PR? It got very out of date :( |
|
It's not a priority at the moment no 👍 |
Description
This PR reverts to using string versions of
svgelements and introduces a customcreateElementfunction for react-native which will be able to map those to native svg elements.It will also be useful to have a custom
createElementfunction in other case, such as having a failover for<div>,<span>...How has this been tested?
To be tested along with wordpress-mobile/gutenberg-mobile#184
WIP
Types of changes
Build changes
Checklist: