svg-sprite
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -9,3 +9,3 @@ 'use strict'; | ||
* @author Joschi Kuphal <joschi@kuphal.net> (https://github.com/jkphl) | ||
* @copyright © 2014 Joschi Kuphal | ||
* @copyright © 2015 Joschi Kuphal | ||
* @license MIT https://raw.github.com/jkphl/svg-sprite/master/LICENSE.txt | ||
@@ -12,0 +12,0 @@ */ |
@@ -9,3 +9,3 @@ 'use strict'; | ||
* @author Joschi Kuphal <joschi@kuphal.net> (https://github.com/jkphl) | ||
* @copyright © 2014 Joschi Kuphal | ||
* @copyright © 2015 Joschi Kuphal | ||
* @license MIT https://raw.github.com/jkphl/svg-sprite/master/LICENSE | ||
@@ -12,0 +12,0 @@ */ |
@@ -9,3 +9,3 @@ 'use strict'; | ||
* @author Joschi Kuphal <joschi@kuphal.net> (https://github.com/jkphl) | ||
* @copyright © 2014 Joschi Kuphal | ||
* @copyright © 2015 Joschi Kuphal | ||
* @license MIT https://raw.github.com/jkphl/svg-sprite/master/LICENSE | ||
@@ -12,0 +12,0 @@ */ |
@@ -9,3 +9,3 @@ 'use strict'; | ||
* @author Joschi Kuphal <joschi@kuphal.net> (https://github.com/jkphl) | ||
* @copyright © 2014 Joschi Kuphal | ||
* @copyright © 2015 Joschi Kuphal | ||
* @license MIT https://raw.github.com/jkphl/svg-sprite/master/LICENSE | ||
@@ -12,0 +12,0 @@ */ |
@@ -9,3 +9,3 @@ 'use strict'; | ||
* @author Joschi Kuphal <joschi@kuphal.net> (https://github.com/jkphl) | ||
* @copyright © 2014 Joschi Kuphal | ||
* @copyright © 2015 Joschi Kuphal | ||
* @license MIT https://raw.github.com/jkphl/svg-sprite/master/LICENSE | ||
@@ -12,0 +12,0 @@ */ |
@@ -9,3 +9,3 @@ 'use strict'; | ||
* @author Joschi Kuphal <joschi@kuphal.net> (https://github.com/jkphl) | ||
* @copyright © 2014 Joschi Kuphal | ||
* @copyright © 2015 Joschi Kuphal | ||
* @license MIT https://raw.github.com/jkphl/svg-sprite/master/LICENSE | ||
@@ -12,0 +12,0 @@ */ |
@@ -9,3 +9,3 @@ 'use strict'; | ||
* @author Joschi Kuphal <joschi@kuphal.net> (https://github.com/jkphl) | ||
* @copyright © 2014 Joschi Kuphal | ||
* @copyright © 2015 Joschi Kuphal | ||
* @license MIT https://raw.github.com/jkphl/svg-sprite/master/LICENSE | ||
@@ -65,3 +65,3 @@ */ | ||
var inline = !!this.config.inline, | ||
svg = new SVGSprite(xmlDeclaration, doctypeDeclaration, inline ? { | ||
svg = new SVGSprite(!inline && xmlDeclaration, !inline && doctypeDeclaration, inline ? { | ||
width : 0, | ||
@@ -68,0 +68,0 @@ height : 0, |
@@ -9,3 +9,3 @@ 'use strict'; | ||
* @author Joschi Kuphal <joschi@kuphal.net> (https://github.com/jkphl) | ||
* @copyright © 2014 Joschi Kuphal | ||
* @copyright © 2015 Joschi Kuphal | ||
* @license MIT https://raw.github.com/jkphl/svg-sprite/master/LICENSE | ||
@@ -65,8 +65,3 @@ */ | ||
SVGSpriteStack.prototype._buildSVG = function(xmlDeclaration, doctypeDeclaration) { | ||
var inline = !!this.config.inline, | ||
svg = new SVGSprite(xmlDeclaration, doctypeDeclaration, inline ? { | ||
width : 0, | ||
height : 0, | ||
style : 'position:absolute' | ||
} : {}, !inline); | ||
svg = new SVGSprite(xmlDeclaration, doctypeDeclaration); | ||
svg.add('<style>:root>svg{display:none}:root>svg:target{display:block}</style>'); | ||
@@ -73,0 +68,0 @@ svg.add(_.pluck(this.data.shapes, 'svg')); |
@@ -9,3 +9,3 @@ 'use strict'; | ||
* @author Joschi Kuphal <joschi@kuphal.net> (https://github.com/jkphl) | ||
* @copyright © 2014 Joschi Kuphal | ||
* @copyright © 2015 Joschi Kuphal | ||
* @license MIT https://raw.github.com/jkphl/svg-sprite/master/LICENSE | ||
@@ -12,0 +12,0 @@ */ |
@@ -9,3 +9,3 @@ 'use strict'; | ||
* @author Joschi Kuphal <joschi@kuphal.net> (https://github.com/jkphl) | ||
* @copyright © 2014 Joschi Kuphal | ||
* @copyright © 2015 Joschi Kuphal | ||
* @license MIT https://raw.github.com/jkphl/svg-sprite/master/LICENSE | ||
@@ -74,3 +74,3 @@ */ | ||
var inline = !!this.config.inline, | ||
svg = new SVGSprite(xmlDeclaration, doctypeDeclaration, inline ? { | ||
svg = new SVGSprite(!inline && xmlDeclaration, !inline && doctypeDeclaration, inline ? { | ||
width : 0, | ||
@@ -81,3 +81,3 @@ height : 0, | ||
svg.add(_.pluck(this.data.shapes, 'svg')); | ||
return svg.toFile(this._spriter.config.dest, this.config.sprite); | ||
@@ -84,0 +84,0 @@ } |
@@ -9,3 +9,3 @@ 'use strict'; | ||
* @author Joschi Kuphal <joschi@kuphal.net> (https://github.com/jkphl) | ||
* @copyright © 2014 Joschi Kuphal | ||
* @copyright © 2015 Joschi Kuphal | ||
* @license MIT https://raw.github.com/jkphl/svg-sprite/master/LICENSE | ||
@@ -12,0 +12,0 @@ */ |
@@ -9,3 +9,3 @@ 'use strict'; | ||
* @author Joschi Kuphal <joschi@kuphal.net> (https://github.com/jkphl) | ||
* @copyright © 2014 Joschi Kuphal | ||
* @copyright © 2015 Joschi Kuphal | ||
* @license MIT https://raw.github.com/jkphl/svg-sprite/master/LICENSE | ||
@@ -12,0 +12,0 @@ */ |
@@ -9,3 +9,3 @@ 'use strict'; | ||
* @author Joschi Kuphal <joschi@kuphal.net> (https://github.com/jkphl) | ||
* @copyright © 2014 Joschi Kuphal | ||
* @copyright © 2015 Joschi Kuphal | ||
* @license MIT https://raw.github.com/jkphl/svg-sprite/master/LICENSE | ||
@@ -16,2 +16,3 @@ */ | ||
path = require('path'), | ||
util = require('util'), | ||
xmldom = require('xmldom'), | ||
@@ -29,2 +30,7 @@ DOMParser = xmldom.DOMParser, | ||
async = require('async'), | ||
createIdGenerator = function(template) { | ||
return function(name) { | ||
return util.format(template || '%s', path.basename(name.split(path.sep).join(this.separator), '.svg')); | ||
} | ||
}, | ||
defaultConfig = { | ||
@@ -55,5 +61,3 @@ /** | ||
*/ | ||
generator : function(name) { | ||
return path.basename(name.split(path.sep).join(this.separator), '.svg'); | ||
} | ||
generator : createIdGenerator('%s') | ||
}, | ||
@@ -121,3 +125,8 @@ /** | ||
this.config = _.merge(_.clone(defaultConfig, true), this.spriter.config.shape || {}); | ||
this.id = (_.isFunction(this.config.id.generator) ? this.config.id.generator(this.name) : null) || defaultConfig.id.generator(this.name); | ||
if (!_.isFunction(this.config.id.generator)) { | ||
this.config.id.generator = createIdGenerator(_.isString(this.config.id.generator) ? (this.config.id.generator + ((this.config.id.generator.indexOf('%s') >= 0) ? '' : '%s')) : '%s'); | ||
} | ||
this.id = this.config.id.generator(this.name); | ||
this.state = this.id.split(this.config.id.pseudo); | ||
@@ -124,0 +133,0 @@ this.base = this.state.shift(); |
@@ -9,3 +9,3 @@ 'use strict'; | ||
* @author Joschi Kuphal <joschi@kuphal.net> (https://github.com/jkphl) | ||
* @copyright © 2014 Joschi Kuphal | ||
* @copyright © 2015 Joschi Kuphal | ||
* @license MIT https://raw.github.com/jkphl/svg-sprite/master/LICENSE | ||
@@ -28,3 +28,3 @@ */ | ||
this.doctypeDeclaration = doctypeDeclaration || ''; | ||
this.rootAttributes = rootAttributes; | ||
this.rootAttributes = _.extend({}, rootAttributes); | ||
this.content = []; | ||
@@ -31,0 +31,0 @@ |
@@ -9,3 +9,3 @@ 'use strict'; | ||
* @author Joschi Kuphal <joschi@kuphal.net> (https://github.com/jkphl) | ||
* @copyright © 2014 Joschi Kuphal | ||
* @copyright © 2015 Joschi Kuphal | ||
* @license MIT https://raw.github.com/jkphl/svg-sprite/master/LICENSE | ||
@@ -12,0 +12,0 @@ */ |
The MIT License (MIT) | ||
Copyright © 2014 Joschi Kuphal | ||
Copyright © 2015 Joschi Kuphal | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of |
{ | ||
"name": "svg-sprite", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Joschi Kuphal", |
@@ -414,3 +414,3 @@ svg-sprite [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependency Status][depstat-image]][depstat-url] | ||
`id.separator` | String | `--` | Separator for traversing a directory structure into a shape ID | | ||
`id.generator` | Function | See desc. | Callback for translating the local part of the file name into a shape ID. The callback's signature is `function(name) { /* ... */ return id; }`. By default, directory structures are traversed using the `id.separator` as replacement for the directory separator. | | ||
`id.generator` | Function∣String | See desc. | Callback for translating the local part of a shape's file name into a shape ID. The callback's signature is `function(name) { /* ... */ return id; }`. By default, the file extension `".svg"` is stripped off and directory structures get traversed using the `id.separator` as replacement for the directory separator. You may also provide a template string (e.g. `"icon-%s"`), in which case the placeholder `"%s"` gets substituted with the traversed local file name. If the string doesn't contain any placeholder, it is used as a prefix to the local file name. | | ||
`id.pseudo` | String | `~` | String separator for pseudo CSS classes in file names. Example: `my-icon.svg` and `my-icon~hover.svg` for an icon with a regular and a `:hover` state. | | ||
@@ -911,2 +911,6 @@ `dimension.maxWidth` | Integer | `2000` | Maximum shape width in pixels | | ||
#### v1.0.4 Bufix release | ||
* Fixed XML & doctype declaration bug with inline sprites ([gulp-svg-sprite #2](https://github.com/jkphl/gulp-svg-sprite/issues/2)) | ||
* Added support for ID generator templates ([#37](https://github.com/jkphl/svg-sprite/issues/37)) | ||
#### v1.0.3 Bufix release | ||
@@ -939,3 +943,3 @@ * Fixed dependency error ([#36](https://github.com/jkphl/svg-sprite/issues/36)) | ||
----- | ||
Copyright © 2014 Joschi Kuphal <joschi@kuphal.net> / [@jkphl](https://twitter.com/jkphl) | ||
Copyright © 2015 Joschi Kuphal <joschi@kuphal.net> / [@jkphl](https://twitter.com/jkphl) | ||
@@ -942,0 +946,0 @@ *svg-sprite* is licensed under the terms of the [MIT license](LICENSE.txt). |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3203
958
8412701
68