mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Add svg-sprite
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
/// <reference path="svg-sprite.d.ts" />
|
||||
|
||||
import SVGSpriter = require('svg-sprite');
|
||||
import * as fs from 'fs';
|
||||
|
||||
var config: any = null;
|
||||
|
||||
// Create spriter instance (see below for `config` examples)
|
||||
var spriter = new SVGSpriter(config);
|
||||
|
||||
// Add SVG source files — the manual way ...
|
||||
spriter.add('assets/svg-1.svg', null, fs.readFileSync('assets/svg-1.svg', {encoding: 'utf-8'}));
|
||||
spriter.add('assets/svg-2.svg', null, fs.readFileSync('assets/svg-2.svg', {encoding: 'utf-8'}));
|
||||
/* ... */
|
||||
|
||||
// Compile the sprite
|
||||
spriter.compile(function(error: any, result: any) {
|
||||
/* ... Write `result` files to disk or do whatever with them ... */
|
||||
});
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
// Type definitions for svg-sprite
|
||||
// Project: https://github.com/jkphl/svg-sprite
|
||||
// Definitions by: Qubo <https://github.com/tkqubo>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../vinyl/vinyl.d.ts" />
|
||||
|
||||
declare module "svg-sprite" {
|
||||
import File = require('vinyl');
|
||||
|
||||
namespace sprite {
|
||||
interface SVGSpriterConstructor {
|
||||
new(config: any): SVGSpriter;
|
||||
}
|
||||
|
||||
interface SVGSpriter {
|
||||
add(file: string|File, name: string, svg: string): SVGSpriter;
|
||||
compile(config: any, callback: CompileCallback): SVGSpriter;
|
||||
compile(callback: CompileCallback): void;
|
||||
getShapes(dest: string, callback: GetShapesCallback): void;
|
||||
}
|
||||
|
||||
interface CompileCallback {
|
||||
(error: any, result: any, data: any): any;
|
||||
}
|
||||
|
||||
interface GetShapesCallback {
|
||||
(error: any, result: File[]): any;
|
||||
}
|
||||
}
|
||||
|
||||
var sprite: sprite.SVGSpriterConstructor;
|
||||
|
||||
export = sprite;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user