Skip to content

Commit 80e2c14

Browse files
committed
Add Mode definition to svg-sprite
1 parent c1aad0b commit 80e2c14

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

svg-sprite/svg-sprite.d.ts

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,106 @@ declare module "svg-sprite" {
212212
}
213213

214214
interface Mode {
215+
css?: CssAndViewSpecificModeConfig|boolean;
216+
view?: CssAndViewSpecificModeConfig|boolean;
217+
defs?: DefsAndSymbolSpecificModeConfig|boolean;
218+
symbol?: DefsAndSymbolSpecificModeConfig|boolean;
219+
stack?: ModeConfig|boolean;
220+
[customConfigName: string]: ModeConfig;
221+
}
222+
223+
interface ModeConfig {
224+
/**
225+
* Base directory for sprite and CSS file output. If not absolute, the path will be resolved using the main output directory (see global dest option).
226+
* @default "<mode>"
227+
*/
228+
dest?: string;
229+
/**
230+
* Used for prefixing the [shape ID](#shape-ids) during CSS selector construction. If the value is empty,
231+
* no prefix will be used. The prefix may contain the placeholder "%s" (e.g. ".svg %s-svg"),
232+
* which will then get replaced by the shape ID. Please be aware that "%" is a special character
233+
* in this context and that you'll have to escape it by another percent sign ("%%") in case you want
234+
* to output it to your stylesheets (e.g. for a [Sass placeholder selector](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#placeholder_selectors_)).
235+
* @default ".svg-%s"
236+
*/
237+
prefix?: string;
238+
/**
239+
* A non-empty string value will trigger the creation of additional CSS rules specifying the dimensions of each shape in the sprite.
240+
* The string will be used as suffix to mode.<mode>.prefix during CSS selector construction and may contain the placeholder "%s",
241+
* which will get replaced by the value of mode.<mode>.prefix.
242+
* A boolean TRUE will cause the dimensions to be included directly into each shape's CSS rule (only available for «css» and «view» sprites).
243+
* @default "-dims"
244+
*/
245+
dimensions?: string|boolean;
246+
/**
247+
* SVG sprite path and file name, relative to the mode.<mode>.dest directory.
248+
* You may omit the file extension, in which case it will be set to ".svg" automatically.
249+
* @default "svg/sprite.<mode>.svg"
250+
*/
251+
sprite?: string;
252+
/**
253+
* Add a content based hash to the name of the sprite file so that clients reliably reload the sprite
254+
* when it's content changes («cache busting»). Defaults to false except for «css» and «view» sprites.
255+
* @default true∣false
256+
*/
257+
bust?: boolean;
258+
/**
259+
* Collection of [stylesheet rendering configurations](#rendering-configurations).
260+
* The keys are used as file extensions as well as file return keys. At present,
261+
* there are default templates for the file extensions css ([CSS](http://www.w3.org/Style/CSS/)),
262+
* scss ([Sass](http://sass-lang.com/)), less ([Less](http://lesscss.org/)) and styl ([Stylus](http://learnboost.github.io/stylus/)),
263+
* which all reside in the directory tmpl/css. Example: {css: true, scss: {dest: '_sprite.scss'}}
264+
* @default {}
265+
*/
266+
render?: { [key: string]: RenderingConfiguration };
267+
/**
268+
* Enabling this will trigger the creation of an HTML document demoing the usage of the sprite. Please see below for details on [rendering configurations](#rendering-configurations).
269+
* @default false
270+
*/
271+
example?: RenderingConfiguration;
272+
}
215273

274+
interface RenderingConfiguration {
275+
/**
276+
* HTML document Mustache template
277+
* @default "tmpl/<mode>/sprite.html"
278+
*/
279+
template?: string;
280+
/**
281+
* HTML document destination
282+
* @default "sprite.<mode>.html"
283+
*/
284+
dest?: string;
285+
}
286+
287+
interface CssAndViewSpecificModeConfig extends ModeConfig {
288+
/**
289+
* The arrangement of the shapes within the sprite. Might be "vertical", "horizontal", "diagonal" or "packed"
290+
* (with the latter being the most compact type). It depends on your project which layout is best for you.
291+
* @default "packed"
292+
*/
293+
layout?: string;
294+
/**
295+
* If given and not empty, this will be the selector name of a CSS rule commonly specifying the background-image
296+
* and background-repeat properties for all the shapes in the sprite (thus saving some bytes by not unnecessarily repeating them for each shape)
297+
*/
298+
common?: string;
299+
/**
300+
* If given and not empty, a mixin with this name will be added to supporting output formats (e.g. Sass, LESS, Stylus),
301+
* specifying the background-image and background-repeat properties for all the shapes in the sprite.
302+
* You may use it for creating custom CSS within @media rules. The mixin acts much like the common rule.
303+
* In fact, you can even combine the two - if both are enabled, the common rule will use the mixin internally.
304+
*/
305+
mixin?: string;
306+
}
307+
308+
interface DefsAndSymbolSpecificModeConfig extends ModeConfig {
309+
/**
310+
* If you want to embed the sprite into your HTML source, you will want to set this to true
311+
* in order to prevent the creation of SVG namespace declarations and to set some other attributes for effectively hiding the library sprite.
312+
* @default false
313+
*/
314+
inline?: boolean;
216315
}
217316

218317
interface CompileCallback {

0 commit comments

Comments
 (0)