Skip to content

Commit

Permalink
Merge pull request #12 from Desire2Learn-Valence/dbatiste/less-encode…
Browse files Browse the repository at this point in the history
…-icons

Changing generated less to include 64-bit encoded version of icons rathe...
  • Loading branch information
dbatiste committed Oct 30, 2014
2 parents f64afad + 16b42ea commit a92999a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions icon-less.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ var generateLess = function( iconPaths, lessPath ) {
var iconInfo = iconInfos[i];
if ( !iconInfo.isRtl ) {



less.write( ' .' + mixinPrefix + iconInfo.name + '() {\n' );
less.write( ' &:before {\n' );
less.write( ' content: data-uri(\'image/png;base64\',\'' + iconInfo.path + '\');\n' );
less.write( ' content: url("data:image/png;base64,' + iconInfo.icon.toString( 'base64' ) + '");\n' );
var rtlIconInfo = tryGetRtlIcon( iconInfo );
if ( rtlIconInfo ) {
less.write( ' [dir=\'rtl\'] & {\n' );
less.write( ' content: data-uri(\'image/png;base64\',\'' + rtlIconInfo.path + '\');\n' );
less.write( ' content: url("data:image/png;base64,' + rtlIconInfo.icon.toString( 'base64' ) + '");\n' );
less.write( ' }\n' );
}
less.write( ' }\n' );
Expand Down Expand Up @@ -95,7 +97,7 @@ var forEachIcon = function( iconPaths, delegate ) {
deferred = require( 'q' ).defer(),
vfs = require( 'vinyl-fs' );

vfs.src( iconPaths, { base: './' } ).pipe(
vfs.src( iconPaths, { base: './' } ).pipe(
through2.obj( function( file, enc, done ) {

var fileName = file.path.replace( /^.*[\\\/]/, '' );
Expand All @@ -104,14 +106,14 @@ var forEachIcon = function( iconPaths, delegate ) {

var isRtl = ( fileName.length > 4 && fileName.substr( fileName.length - 4, 4 ) == '_rtl' );

//var iconName = 'vui-icon-' + fileName.replace( '_', '-' );
var iconName = fileName.replace( '_', '-' );
if ( isRtl ) {
iconName = iconName.substr( 0, iconName.length - 4 );
}

delegate( {
name: iconName,
icon: file.contents,
isRtl: isRtl,
path: file.relative
} );
Expand All @@ -130,4 +132,4 @@ var forEachIcon = function( iconPaths, delegate ) {
module.exports = {
generateLess: generateLess,
generateStyle: generateStyle
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vui-icons",
"description": "LESS mixins, CSS and image assets for consuming icons",
"version": "0.1.1",
"version": "0.2.0",
"author": "D2L Corporation",
"license": "Apache-2.0",
"repository": {
Expand Down

0 comments on commit a92999a

Please sign in to comment.