question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

remove explicit svg inline styles

See original GitHub issue

the generated svg element has an inline width and height style, making responsive overrides ugly or difficult.

the inline styles are applied here: https://github.com/urbit/sigil-js/blob/master/lib/src/index.js#L164

and result in an SVG that does not scale to its container

explicit width/height: image

unset width and height (default behavior is to expand to parent size):

image

to be clear: responsive height is preferred. only the viewbox is necessary, since that tells the browser how an svg should be scaled.

if a consumer wants a sigil to be an explicit and constant size they can easily do that with

<div style={{width: size, height: size}}>
  {sigil({size, renderer: reactRenderer, ...})}
</div>

wheras to override these styles I must have a global style rule like

svg {
  width: inherit !important;
  height: inherit !important;
}

which is ugly and will definitely come back to bite a programmer in the future.

solving this issue will also solve: #30

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
shrugscommented, Jul 23, 2019

the caller should still set size, so that the stroke width and viewbox is set correctly, if that’s what you mean. the idea is that the caller would set an ‘expected’ size the sigil would display at, but then be free to display it at more or less depending on the responsive parent.

0reactions
g-a-v-i-ncommented, Jul 24, 2019

resolved in #39 and published in 1.3.5

Read more comments on GitHub >

github_iconTop Results From Across the Web

remove inline style on a svg image - css - Stack Overflow
I hope it will work, try this code. body{background:#ccc;} .navtsvg{ float:left; height:17px; width:19px; } .fil0{ fill:white; }
Read more >
5 Gotchas You're Gonna Face Getting Inline SVG Into ...
My recommendation is to just hide/show via CSS classes (Technique #1 described in Swapping Out SVG Icons article), and be sure to target...
Read more >
<use> - SVG: Scalable Vector Graphics - MDN Web Docs
The element takes nodes from within the SVG document, and duplicates them ... by the cloned DOM unless you explicitly request them using...
Read more >
Document Structure — SVG 2
The following example shows simple SVG content embedded inline as a fragment within a ... so an explicit namespace prefix must be assigned...
Read more >
Styling SVG <use> Content with CSS - Codrops
Next we need to remove the fill presentation attribute from the other drop, and let it inherit the fill color from use without...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found