Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# gulp-svg-css
[![Build Status](https://travis-ci.org/sdl/gulp-svg-css.svg?branch=master)](https://travis-ci.org/sdl/gulp-svg-css)
[![Coverage Status](https://coveralls.io/repos/github/sdl/gulp-svg-css/badge.svg?branch=master)](https://coveralls.io/github/sdl/gulp-svg-css?branch=master)
[![npm version](https://badge.fury.io/js/gulp-svg-css.svg)](https://badge.fury.io/js/gulp-svg-css)
[![Dependency Status](https://david-dm.org/sdl/gulp-svg-css.svg)](https://david-dm.org/sdl/gulp-svg-css)
[![devDependency Status](https://david-dm.org/sdl/gulp-svg-css/dev-status.svg)](https://david-dm.org/sdl/gulp-svg-css#info=devDependencies)
# gulp-svg-css-pseudo
[![npm version](https://badge.fury.io/js/gulp-svg-css-pseudo.svg)](https://badge.fury.io/js/gulp-svg-css-pseudo)
[![Dependency Status](https://david-dm.org/budfy/gulp-svg-css-pseudo.svg)](https://david-dm.org/budfy/gulp-svg-css-pseudo)
[![devDependency Status](https://david-dm.org/budfy/gulp-svg-css-pseudo/dev-status.svg)](https://david-dm.org/budfy/gulp-svg-css-pseudo#info=devDependencies)

Gulp plugin that embeds svg images inside a single CSS file using data-uri.

Expand Down Expand Up @@ -93,7 +91,7 @@ Similar to defaultWidth, but for height.

## License

Copyright (c) 2015 All Rights Reserved by the SDL Group.
Copyright (c) 2021 All Rights Reserved by the SDL Group.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
25 changes: 23 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,26 @@ module.exports = function (options) {
*/
function buildCssRule(normalizedFileName, encodedSvg, width, height) {
var cssRule = [];
cssRule.push(options.cssSelector + options.cssPrefix + normalizedFileName + ' {');
cssRule.push(options.cssSelector + options.cssPrefix + normalizedFileName + ',' +
options.cssSelector + options.cssPrefix + normalizedFileName + '-before::before' + ',' +
options.cssSelector + options.cssPrefix + normalizedFileName + '-after::after' + '{');
cssRule.push(' background-image: url("data:image/svg+xml;charset=utf8, ' + encodedSvg + '");');
cssRule.push('}');
if (options.addSize) {
cssRule.push(options.cssSelector + options.cssPrefix + normalizedFileName + '{')
cssRule.push(' width: ' + width + ';');
cssRule.push(' height: ' + height + ';');
cssRule.push('}');
}
cssRule.push(options.cssSelector + options.cssPrefix + normalizedFileName + '-before::before' + ' {');
cssRule.push(' content:\'\';');
if (options.addSize) {
cssRule.push(' width: ' + width + ';');
cssRule.push(' height: ' + height + ';');
}
cssRule.push('}');
cssRule.push(options.cssSelector + options.cssPrefix + normalizedFileName + '-after::after' + ' {');
cssRule.push(' content:\'\';');
if (options.addSize) {
cssRule.push(' width: ' + width + ';');
cssRule.push(' height: ' + height + ';');
Expand Down Expand Up @@ -103,7 +121,10 @@ module.exports = function (options) {
height = height + 'px';
}

return { width: width, height: height };
return {
width: width,
height: height
};
}

var cssRules = [];
Expand Down
20 changes: 13 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gulp-svg-css",
"version": "1.3.0",
"description": "Gulp plugin that embeds svg images inside a single CSS file using data-uri.",
"name": "gulp-svg-css-pseudo",
"version": "1.0.2",
"description": "Gulp plugin that embeds svg images inside a single CSS file using data-uri. Created on the basis of the plugin gulp-svg-css by Jan Bevers",
"main": "index.js",
"scripts": {
"test": "_mocha",
Expand All @@ -10,18 +10,20 @@
},
"repository": {
"type": "git",
"url": "https://github.com/sdl/gulp-svg-css.git"
"url": "git+https://github.com/budfy/gulp-svg-css-pseudo.git"
},
"keywords": [
"gulpplugin",
"svg",
"css",
"pseudoelements",
"inline",
"minification"
],
"author": {
"name": "Jan Bevers",
"email": "jbevers@sdl.com"
"name": "budfy",
"email": "serdyuk.ro@gmail.com",
"github profile": "https://github.com/budfy"
},
"license": "Apache-2.0",
"devDependencies": {
Expand All @@ -35,5 +37,9 @@
"gulp-util": "^3.0.7",
"through2": "^2.0.1",
"xmldom": "^0.1.22"
}
},
"bugs": {
"url": "https://github.com/sdl/gulp-svg-css/issues"
},
"homepage": "https://github.com/budfy/gulp-svg-css-pseudo#readme"
}