From 0c0877269d4075c8588b900cf7c3874267c0349e Mon Sep 17 00:00:00 2001 From: codecalm Date: Tue, 10 Mar 2020 00:29:22 +0100 Subject: icons sprite --- demo/icons-stroke.svg | 19 ++ demo/icons.svg | 883 ++++++++++++++++++++++++++++++++++++++++++++++++++ gulpfile.js | 33 +- icons-sprite.svg | 1 + icons-stroke.svg | 19 -- icons.svg | 883 -------------------------------------------------- package.json | 2 +- readme.md | 4 +- 8 files changed, 935 insertions(+), 909 deletions(-) create mode 100644 demo/icons-stroke.svg create mode 100644 demo/icons.svg create mode 100644 icons-sprite.svg delete mode 100644 icons-stroke.svg delete mode 100644 icons.svg diff --git a/demo/icons-stroke.svg b/demo/icons-stroke.svg new file mode 100644 index 00000000..e91bfe86 --- /dev/null +++ b/demo/icons-stroke.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demo/icons.svg b/demo/icons.svg new file mode 100644 index 00000000..72d9e411 --- /dev/null +++ b/demo/icons.svg @@ -0,0 +1,883 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 3db1297b..03f9d56f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,6 +6,33 @@ const gulp = require('gulp'), gulp.task('icons-sprite', function (cb) { + glob("_site/icons/*.svg", {}, function (er, files) { + + let svgContent = ''; + + files.forEach(function (file, i) { + let name = path.basename(file, '.svg'), + svgFile = fs.readFileSync(file), + svgFileContent = svgFile.toString(); + + svgFileContent = svgFileContent + .replace(/]+>/g, '') + .replace(/<\/svg>/g, '') + .replace(/\n+/g, '') + .replace(/>\s+<') + .trim(); + + svgContent += `${svgFileContent}` + }); + + let svg = `${svgContent}`; + + fs.writeFileSync('icons-sprite.svg', svg); + cb(); + }); +}); + +gulp.task('icons-preview', function (cb) { const columnsCount = 17, padding = 29, paddingOuter = 5, @@ -46,7 +73,7 @@ gulp.task('icons-sprite', function (cb) { const svgContent = `\n${svgContentSymbols}\n${svgContentIcons}\n`; - fs.writeFileSync('icons.svg', svgContent); + fs.writeFileSync('demo/icons.svg', svgContent); cb(); }); }); @@ -82,7 +109,7 @@ gulp.task('icons-stroke', function (cb) { const svgContent = `\n${svgContentSymbols}\n${svgContentIcons}\n`; - fs.writeFileSync('icons-stroke.svg', svgContent); + fs.writeFileSync('demo/icons-stroke.svg', svgContent); cb(); }); @@ -102,8 +129,6 @@ gulp.task('optimize', function (cb) { .replace(/\s+"/g, '"') .replace(/\n\n+/g, "\n"); - console.log('file', file); - fs.writeFileSync(file, svgFileContent); }); diff --git a/icons-sprite.svg b/icons-sprite.svg new file mode 100644 index 00000000..7a5a29b2 --- /dev/null +++ b/icons-sprite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icons-stroke.svg b/icons-stroke.svg deleted file mode 100644 index e91bfe86..00000000 --- a/icons-stroke.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/icons.svg b/icons.svg deleted file mode 100644 index 72d9e411..00000000 --- a/icons.svg +++ /dev/null @@ -1,883 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/package.json b/package.json index fa23e087..a0fdaf86 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "main": "gulpfile.js", "scripts": { "optimize": "gulp optimize", - "build": "gulp optimize && gulp build && gulp icons-sprite" + "build": "gulp optimize && gulp build && gulp icons-preview && gulp icons-sprite" }, "description": "", "devDependencies": { diff --git a/readme.md b/readme.md index dc8fbf18..10a9343b 100644 --- a/readme.md +++ b/readme.md @@ -2,8 +2,8 @@ A set of almost 300 free MIT-licensed high-quality SVG icons for you to use in your web projects. -![Tabler icons](./icons.svg) +![Tabler icons](demo/icons.svg) ### Multiple strokes -![Tabler icons](./icons-stroke.svg) +![Tabler icons](demo/icons-stroke.svg) -- cgit v1.2.1