Replies: 6 comments 13 replies
-
Thanks @paulm17! Is there any reason we shouldn't add the best solution into blitz core so it works out of the box for everyone with zero config? |
Beta Was this translation helpful? Give feedback.
-
So I did a bit of a google and found: Babel-plugin-react-svg: It's a couple of years since the last update. SVGR: Has a nice intro to it. https://www.youtube.com/watch?v=geKCzi7ZPkA and last update was 15th Nov. Really simple to install:
Add to webpack:
I was able to switch from babel-plugin-react-svg to SVGR to no noticeable detriments. I think Blitz should use this by default. But I'll give it a while for more feedback. |
Beta Was this translation helpful? Give feedback.
-
Got a slight issue with SVGR. Not sure if it's one to be honest... After installing SVGR and I already have in my global types
Works fine, except when I try to add height, width props to the SVG element. I get a typescript error it's not defined in the react component. No problem I thought. If I change:
to:
and change the types:
I don't get any issues on props. But then I get this:
I've hit a dead-end on this issue. There is even a next plugin, but I couldn't get anywhere with that. If someone can take a look at this. I'd be grateful! Thanks |
Beta Was this translation helpful? Give feedback.
-
Everyone seems very happy with the proposal to add it to blitz core, so let's go with that. You'll add the webpack config here: https://github.com/blitz-js/blitz/blob/canary/packages/core/src/with-blitz.ts#L18 and add the dependency to |
Beta Was this translation helpful? Give feedback.
-
Zarazas posted this in the RFC chan. Is it of any concern? Any input? |
Beta Was this translation helpful? Give feedback.
-
I'm not sure if posting in RFC from April isn't a faux pas, but I'd like to voice my concerns about possible bugs. SVG import can be a footgun unless configured correctly. An SVG exported from design software can contain a suprising amount of It can be worked around, but I'm not sure if the gain outweighs the pain. An example of SVG icon I worked with a few years back (redacted for brevity).<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="130" height="130" viewBox="0 0 130 130">
<defs>
<path id="a" d="M4.537 37.139L41.878 2.892a9.8 9.8 0 0 1 13.405.148l35.605 34.127A14 14 0 0 1 95.2 47.274V95.9c0 5.799-4.701 10.5-10.5 10.5H10.5C4.701 106.4 0 101.699 0 95.9V47.457a14 14 0 0 1 4.537-10.318z"/>
<filter id="b" width="111.6%" height="110.4%" x="-5.8%" y="-3.3%" filterUnits="objectBoundingBox">
<feOffset dy="2" in="SourceAlpha" result="shadowOffsetOuter1"/>
<feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation="1.5"/>
<feColorMatrix in="shadowBlurOuter1" values="0 0 0 0 0.226735433 0 0 0 0 0.437054197 0 0 0 0 0.687818878 0 0 0 0.126584353 0"/>
</filter>
<!-- redacted -->
</defs>
<g fill="none" fill-rule="evenodd">
<g transform="translate(16 8)">
<mask id="c" fill="#fff">
<use xlink:href="#a"/>
</mask>
<use fill="#000" filter="url(#b)" xlink:href="#a"/>
<use fill="#E3ECF3" xlink:href="#a"/>
<!-- redacted -->
</g>
<!-- redacted -->
</g>
</svg> Related issues:
|
Beta Was this translation helpful? Give feedback.
-
Currently there are multiple ways of adding SVG support to Blitz.
I aim to build a recipe to make it much easier for blitz to support SVG, but also add the correct type definition.
Finally, with a recipe in play, documentation can then be made on how to install and use for new users of Blitz. Prior to finding option 2 it was confusing on what to use.
I am interested in feedback from the community with respect to the other options. Perhaps SVGR or next-images provides better support and facilitates more edge cases?
Please let me know your experience and preference for the recipe to use.
Many thanks!
Beta Was this translation helpful? Give feedback.
All reactions