svg-sprite / gulp-svg-sprite

SVG sprites & stacks galore — Gulp plugin wrapping around svg-sprite that reads in a bunch of SVG files, optimizes them and creates SVG sprites and CSS resources in various flavours
MIT License
647 stars 43 forks source link

Prefix and Dimentions (suffix) Formatting #37

Closed brianO3world closed 8 years ago

brianO3world commented 8 years ago

Hey jkphl,

Ok, now in the right repo. Sorry about that... For reference:

Tinkering with the SCSS output from this and having an issue with formatting for the output SCSS classes. Looking at the formatting for this: https://github.com/jkphl/svg-sprite#common-mode-properties

I'm updating the dimensions to have no value, but it actually seems to remove the Prefix as well (including the . for the class).

The Gulp.js Cofig

gulp.task( 'svg-sprite', function( ) {

    var config = {
        shape : {
            spacing : {
                padding : 5
            }
        },
        mode : {
            symbol : {
                bust : false,
                dest : '.',
                dimensions : '',
                layout : 'diagonal',
                prefix : '.icon-%s',
                render : {
                    scss: {
                        dest: 'css/scss/partial/_sprite.scss'
                    }
                },
                sprite : 'img/test.svg' //sprite-svg-ui.svg
            }
        }
    };

    gulp.src( 'img/svg/*.svg', { cwd: '' } )
        .pipe( plumber( { 'errorHandler': onError } ) )
        .pipe( imagemin( ) )
        .pipe( svgsprite( config ) )
        .pipe( gulp.dest( '' ) )
        .pipe( notify( { message: "'svg-sprite' completed" } ) );
} );

_The Output in _sprite.scss:_

 icon-feature-calculations {
    width: 66px;
    height: 59px;
}

There's a space at the start of it where my prefix should be.

Any thoughts?

Thanks, Brian

jkphl commented 8 years ago

Hey @brianO3world,

sorry for not getting back to you earlier!

Well, first of all I have to ask: Why would you want to empty the suffix respectively selector for the dimension classes? Which selector do you expect the dimension classes to get then?

The dimension config option is treated as a string which may contain a placeholder '"%s"' that is substituted by the regular shape selector if found. If there's no such placeholder, then the value will simply be appended to the regular shape selector. What seems somewhat bad is that there's no defined behaviour for the case you're trying — setting the value to an empty string. But IMHO that doesn't make any sense at all ... so what are you really trying to achieve?

Cheers, Joschi

jkphl commented 8 years ago

@brianO3world Any updates on this one?

jkphl commented 8 years ago

Closing this due to missing response. Please feel free to reopen in case you still have troubles.