Skip to content

Commit

Permalink
adds: stylus generator
Browse files Browse the repository at this point in the history
  • Loading branch information
alpadev committed Jan 2, 2014
1 parent c4554cb commit 894a702
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tasks/sprites.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ module.exports = function(grunt) {
return fileContents;
}

function generateStylusFile (imageData, images, placeholder) {
var fileContents = '';

fileContents += '$' + placeholder + '\n background: url("' + generateBackgroundImagePath() + '") no-repeat\n\n';
imageData.heights.forEach(function (height, idx) {
fileContents += '$' + (classPrefix === '' ? '' : classPrefix + '-') + path.basename(images[idx].file, '.png') + '\n @extend $' + placeholder + '\n background-position: 0 ' + ( height > 0 ? -height + 'px' : 0 ) + '\n\n';
});

return fileContents;
}

function runSpriteGenerator (images) {
// spawn a phantom js process
var ps = spawn(binPath, ['--web-security=no', path.resolve(__dirname, '../lib/phantomspriter.js')]);
Expand Down Expand Up @@ -150,6 +161,9 @@ module.exports = function(grunt) {
case "less":
stylesData = generateLESSFile(incomingData, images, placeHolder);
break;
case "stylus":
stylesData = generateStylusFile(incomingData, images, placeHolder);
break;
default:
stylesData = generateCSSFile(incomingData, images);
break;
Expand Down

0 comments on commit 894a702

Please # to comment.