Created
April 10, 2015 23:21
-
-
Save jarcoal/0f8d205598401baaf414 to your computer and use it in GitHub Desktop.
SVG Sprite Color
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var svgColor = function(color) { | |
return function(shape, sprite, callback) { | |
var paths = shape.dom.getElementsByTagName('path'); | |
for (var i = 0; i < paths.length; i++) { | |
paths[i].setAttribute('fill', color); | |
} | |
callback(null); | |
}; | |
}; | |
module.exports = function(grunt) { | |
grunt.initConfig({ | |
svg_sprite: { | |
// ... | |
options: { | |
// svgo must appear in transform list | |
transform: ['svgo', { | |
// 'dark' can be changed for any value | |
dark: svgColor('#FFF') | |
}], | |
} | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment