Skip to content
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

Gradients not rendering #56

Closed
rctneil opened this issue Oct 31, 2015 · 15 comments
Closed

Gradients not rendering #56

rctneil opened this issue Oct 31, 2015 · 15 comments

Comments

@rctneil
Copy link

rctneil commented Oct 31, 2015

Hey,

Been testing out gulp-svgstore for my new site. I have got it working on quite a few SVG's and it's great.

However, any svg's that contain gradients do not render them. On;y the solid fill areas show up. I have read everything I can find to locate a solution but can't seem to get anything to work. I tried moving a linearGradient blog out of the and this allows it to display in Firefox but still nothing in Chrome.

I also have a lot of SVG's and quite a few have a lot of gradients so it's a big issue for me here. Is there a solution to this and if so, is there an automated way that can be done as part of the gulp workflow and svgstore task?

@w0rm
Copy link
Owner

w0rm commented Oct 31, 2015

@rctneil hi, I think this issue is the same as #55
wrap gradients definitions inside defs and check if this works for you

@rctneil
Copy link
Author

rctneil commented Oct 31, 2015

@w0rm I did read that but it doesn't make sense to me. Also, I am using externally referenced SVG so unsure if that makes a difference.

@w0rm
Copy link
Owner

w0rm commented Oct 31, 2015

@rctneil can you provide a source of an example svg that is broken when used from a combined file?

@rctneil
Copy link
Author

rctneil commented Oct 31, 2015

@w0rm Ok, This SVG has a gradient and the gradient part doesn't show in Chrome. If I move the gradient out of the symbol then the gradient parts shows in Firefox but still not in Chrome:

https://gist.github.com/rctneil/a69743e09be0d44ac309?short_path=f99ea3c

@w0rm
Copy link
Owner

w0rm commented Oct 31, 2015

@rctneil I was able to reproduce the issue, wrapping gradient inside defs fixes the issue in Firefox, but not in Chrome.

I'm really not sure why its not working.

@rctneil
Copy link
Author

rctneil commented Oct 31, 2015

@w0rm It's odd. How are other people using this plugin solving the issue? Surely they must be encountering it?

This is happening for every SVG that I have with some form of gradient.

@w0rm
Copy link
Owner

w0rm commented Oct 31, 2015

Maybe they inline combined svg into the page. I'm not using svgstore for complex svgs, but rather for monochrome icons.

@w0rm
Copy link
Owner

w0rm commented Oct 31, 2015

I'd like to see this issue tracked down to an explanation of why its broken or maybe even a Chrome bug report.

@rctneil
Copy link
Author

rctneil commented Oct 31, 2015

@w0rm I've just reverted to an inline option and all the gradients display. Weird.

@w0rm
Copy link
Owner

w0rm commented Oct 31, 2015

@rctneil I was able to find this question on stackoverflow with a links to chromium and webkit bugs. Not sure if its the same issue we're having here.

@daviddarnes
Copy link

@w0rm I don't think it's quite the same as the question refers to an external file. I've just used svgstore on this project and the gradients are missing, all of the SVGs are inline. The first icon in the grid should be shown like this.

Edit: I managed to solve my issue partly by removing visibility: hidden; from my SVG defs wrapping div, and partly by tweaking the names of the linearGradient elements. 3 of them were named linearGradient-1 which was causing conflicts.

@w0rm
Copy link
Owner

w0rm commented Nov 16, 2015

@daviddarnes yes, your issue is different from this one. I'm closing this one because thats how Chrome works, if you use symbols from external svg and they link to gradients or other objects from within that external svg — then the linked objects don't render.

Regarding two gradients with the same id, svgstore simply merges all svgs together, you need to ensure this yourself that ids do not clash. This can be done with gulp-svgmin, check the very first example from the readme https://github.com/w0rm/gulp-svgstore#usage

@w0rm w0rm closed this as completed Nov 16, 2015
@daviddarnes
Copy link

@w0rm thanks for the reply. Upon further investigation it appears that Sketch is quite poor when it comes to naming and managing gradients, it merely numbers them. So when combining SVGs with gradients it will almost always clash. At some point I should probably use cheerio in the gulp task to name the gradients.

Sorry for pointing the blame in the wrong direction. Thanks for open sourcing!

@w0rm
Copy link
Owner

w0rm commented Nov 16, 2015

@daviddarnes why isn't the proposed solution working for you? It ensures unique ids automatically and also minifies svgs

@daviddarnes
Copy link

@w0rm I wasn't using svgmin at the time, thought it was causing another issue. I changed the IDs myself and everything works fine. Despite svgmin solving the gradient issue, it would still be nice if Sketch didn't just number gradients like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants