foundation / foundation-sites

The most advanced responsive front-end framework in the world. Quickly create prototypes and production code for sites that work on any kind of device.
https://get.foundation
MIT License
29.67k stars 5.48k forks source link

No sprites support in foundation environment a.k.a gulpfile #8840

Closed yeomann closed 8 years ago

yeomann commented 8 years ago

I just wonder why foundation setup didn't include or come with built-in sprite support. Any chance you guys will include in future releases or? By the way, if by chance anyone reading this i will show the code that i wrote and it is working for generating sprites and sccs/css add following in your package.json

"gulp-csso": "^1.1.0",
    "vinyl-buffer": "^1.0.0",
    "merge-stream": "^1.0.0",
    "gulp.spritesmith": "^6.2.0",

and this bit in foundation gulpfile.babel file

/*
*   @summary For sprites config only, generating sprite css and image 
 *  @author danish
 */
var csso = require('gulp-csso');
var buffer = require('vinyl-buffer');
var merge = require('merge-stream');
var spritesmith = require('gulp.spritesmith');

function sprite() { 
    var spriteData = gulp.src('src/assets/img/sprite/*.png')
        .pipe(spritesmith({
            imgName: '../img/sprite.png',
            cssName: '_sprite.scss'
        }));
    var spriteImg = spriteData.img.pipe(gulp.dest('src/assets/img'));
    var spriteCss = spriteData.css.pipe(gulp.dest('src/assets/scss/modules/'));
    if (!PRODUCTION) return (spriteImg && spriteCss);
}
and in your watch function add below mentioned line0
gulp.watch('src/assets/img/sprite**/*', gulp.series(sprite, browser.reload));

after doing all of this hazard, just do npm install and drop images which needed to be as sprite in your images folder under sprite folder. For more info and detail see link below. Thank you!

andycochran commented 8 years ago

Sprites are probably too app-specific for the library. But this would make an excellent building block. (As this isn't a bug, I'm going to close the issue.)