Skip to content

Commit bcccc00

Browse files
committed
Add svg-sprite
1 parent 7a3ca1f commit bcccc00

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

svg-sprite/svg-sprite-tests.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/// <reference path="svg-sprite.d.ts" />
2+
3+
import SVGSpriter = require('svg-sprite');
4+
import * as fs from 'fs';
5+
6+
var config: any = null;
7+
8+
// Create spriter instance (see below for `config` examples)
9+
var spriter = new SVGSpriter(config);
10+
11+
// Add SVG source files — the manual way ...
12+
spriter.add('assets/svg-1.svg', null, fs.readFileSync('assets/svg-1.svg', {encoding: 'utf-8'}));
13+
spriter.add('assets/svg-2.svg', null, fs.readFileSync('assets/svg-2.svg', {encoding: 'utf-8'}));
14+
/* ... */
15+
16+
// Compile the sprite
17+
spriter.compile(function(error: any, result: any) {
18+
/* ... Write `result` files to disk or do whatever with them ... */
19+
});

svg-sprite/svg-sprite.d.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Type definitions for svg-sprite
2+
// Project: https://github.com/jkphl/svg-sprite
3+
// Definitions by: Qubo <https://github.com/tkqubo>
4+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
6+
/// <reference path="../vinyl/vinyl.d.ts" />
7+
8+
declare module "svg-sprite" {
9+
import File = require('vinyl');
10+
11+
namespace sprite {
12+
interface SVGSpriterConstructor {
13+
new(config: any): SVGSpriter;
14+
}
15+
16+
interface SVGSpriter {
17+
add(file: string|File, name: string, svg: string): SVGSpriter;
18+
compile(config: any, callback: CompileCallback): SVGSpriter;
19+
compile(callback: CompileCallback): void;
20+
getShapes(dest: string, callback: GetShapesCallback): void;
21+
}
22+
23+
interface CompileCallback {
24+
(error: any, result: any, data: any): any;
25+
}
26+
27+
interface GetShapesCallback {
28+
(error: any, result: File[]): any;
29+
}
30+
}
31+
32+
var sprite: sprite.SVGSpriterConstructor;
33+
34+
export = sprite;
35+
}
36+

0 commit comments

Comments
 (0)