diff --git a/index.js b/index.js
index eadc7eb..9cad8d8 100644
--- a/index.js
+++ b/index.js
@@ -112,17 +112,23 @@ var spriteSVG = function(options) {
// For each sprite
for (var i in data.sprites) {
- var sprite = data.sprites[i],
- // Create, initialise and populate an SVG
- $svg = $('')
- .attr({
- 'height': sprite.h,
- 'viewBox': sprite.viewBox,
- 'width': sprite.w,
- 'x': Math.ceil(sprite.fit.x)+options.padding,
- 'y': Math.ceil(sprite.fit.y)+options.padding
- })
- .append(sprite.file);
+ var sprite = data.sprites[i];
+ // Create, initialise and populate an SVG
+ var spriteAttr = {
+ 'height': sprite.h,
+ 'viewBox': sprite.viewBox,
+ 'width': sprite.w,
+ 'x': Math.ceil(sprite.fit.x)+options.padding,
+ 'y': Math.ceil(sprite.fit.y)+options.padding
+ };
+
+ if (sprite.fill){
+ Object.assign(spriteAttr, {'fill': sprite.fill});
+ }
+
+ var $svg = $('')
+ .attr(spriteAttr)
+ .append(sprite.file);
// Check and set parent SVG width
if(sprite.fit.x+sprite.w+options.padding>data.width) {
@@ -168,15 +174,21 @@ var spriteSVG = function(options) {
sprite.y = y+options.padding;
// Create, initialise and populate an SVG
+ var svgSpriteAttrs = {
+ 'height': sprite.h,
+ 'viewBox': sprite.viewBox,
+ 'width': sprite.w,
+ 'x': Math.ceil(sprite.x),
+ 'y': Math.ceil(sprite.y)
+ };
+
+ if (sprite.fill) {
+ Object.assign(svgSpriteAttrs, {'fill': sprite.fill});
+ }
+
var $svg = $('')
- .attr({
- 'height': sprite.h,
- 'viewBox': sprite.viewBox,
- 'width': sprite.w,
- 'x': Math.ceil(sprite.x),
- 'y': Math.ceil(sprite.y)
- })
- .append(sprite.file);
+ .attr(svgSpriteAttrs)
+ .append(sprite.file);
// Round up coordinates
sprite.h = Math.ceil(sprite.h);
@@ -250,6 +262,10 @@ var spriteSVG = function(options) {
w: parseFloat(width)
};
+ if ($file.attr('fill') !== undefined) {
+ Object.assign(sprite, {fill: $file.attr('fill')});
+ }
+
// Add the sprite to our array
data.sprites.push(sprite);
diff --git a/package-lock.json b/package-lock.json
index 4bd6ea0..ea8a647 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "gulp-svg-spritesheet",
- "version": "0.0.5",
+ "version": "0.0.6",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/package.json b/package.json
index 8965324..b71efe2 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "gulp-svg-spritesheet",
"description": "Gulp SVG sprite sheet generator",
- "version": "0.0.5",
+ "version": "0.0.6",
"author": "Darren Hall ",
"contributors": [
{