diff --git a/README.md b/README.md index 715aea5..35891e1 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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. diff --git a/index.js b/index.js index 2f266f8..b6c358f 100644 --- a/index.js +++ b/index.js @@ -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 + ';'); @@ -103,7 +121,10 @@ module.exports = function (options) { height = height + 'px'; } - return { width: width, height: height }; + return { + width: width, + height: height + }; } var cssRules = []; diff --git a/package.json b/package.json index 7671d9f..433bf1d 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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": { @@ -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" }