Wrapping container for SVG
See original GitHub issueThanks in advance on this. I am trying to add a container around the exported SVG. In this case a <div>. So what is returned would look like this:
<div>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" {...props}>
.......
</svg>
</div>
I am following the example under Custom Templates and looked through the issues and found this solution thinking it would work. Cannot use JSX in custom template
function template({ template }, opts, { imports, componentName, props, jsx, exports }) {
const jsxTemplate = template.smart({ plugins: ['jsx'] });
return jsxTemplate.ast`${imports}
const ${componentName} = (${props}) => <div>{${jsx}}</div>
${exports}
`;
}
module.exports = template;
But I end up with
<div>
{
<svg>
Is there a way to prepend and append content before the ${jsx} is returned?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
resize svg wrapped in div that is wrapped in div - Stack Overflow
I was using nested SVGs before and now I'm told I have to use nested divs with inline SVG. Basically, I need the...
Read more >SVG ONLY Parchment Paper Plastic Wrap and Aluminum Foil ...
This is my own design for an organizer to hold my parchment paper, plastic wrap and aluminum foil rolls. It can be wall...
Read more >How to make an svg scale with its parent container
The <svg> element wraps the rectangle image. The SVG element occupies 100% width of the parent container and its height is auto-adjusted ...
Read more >32 SVG Bags,Boxes,Containers,3D etc ideas - Pinterest
Jul 13, 2015 - Explore Pat Root's board "SVG Bags,Boxes,Containers,3D etc", followed by 523 people on Pinterest. See more ideas about box template,...
Read more >Resizing an SVG When the Window is Resized in d3.js - Chartio
The browser doesn't inherently associate a width or height with an SVG unless you ... The SVG object needs to be wrapped in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m also experiencing this problem. If @gregberge 's suggested fix here doesn’t work, can this ticket be reclassified as a bug?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.