Closed TylerYang closed 8 years ago
Unfortunately the fill property content is a <paint>
value http://www.w3.org/TR/SVG/painting.html#SpecifyingPaint
It means it is a bit complexer than just specifying a color. You should at least test if the attribute value is a color and then fill it only if it match. You also could pick parent fill value if the inherit value is found (see this function that does a similar job https://github.com/nfroidure/svgicons2svgfont/blob/a28c981bfff2dc49f999a358f52728beea09bae0/src/index.js#L43 )
That make sense, I will PR a new one later.
Here is my question, What if there are more than one fill attribute in svg element and their value are different?
For example,
<svg>
<g>
<path fill="#F00" d="M4.." />
</g>
<path fill="#CCC" />
</svg>
In this case, I will simply set the last fill attribute(Only if it is a valid value) to glyph
.
Hi @nfroidure , do you accept with this PR? Because this is really important for my project. Any comments are welcome. Thx.
Just looked at your PR but it comes with no test at all. Can't merge without at least one test.
My bad, I will submit the test case tomorrow. Thx...
@nfroidure Hi, just added some test cases. Looking forward to your advise. Thx.
@TylerYang sorry for the elapsed time, couldn't review your work yet. I'll look at it this week.
@nfroidure It's OK, I will be waiting.
Can you review this PR also? https://github.com/nfroidure/gulp-svgicons2svgfont/pull/31 It failed to pass the tests because in preview svgicons2svgfont
module, it didn't have the color
property.
You can easily make it pass by using your repo's url. I'll try to review it asap anyway.
@nfroidure I would like to do it so, but seems in China, I cannot access to this url at this moment. All I can get is ERR:TIMEOUT
from their CDN.
Anyway, thx for your help. This lib did improve the dev&prod experience a lot.
Map attribute 'fill' to color property