Closed ocrest closed 9 years ago
Totally agree with you, those additional mixins can prove very useful.
_image, _size, etc.
to -image, -size
(I just dislike underscores in css)Can we change the syntax from
_image, _size, etc.
to-image, -size
(I just dislike underscores in css)
In Sass dashes and underscores are interchangeable, so the mixin named sprite_image
can be included both with
@include sprite-image;
and
@include sprite_image;
But I've just replaced all underscores with dashes to make all things look same :)
Are the additional variables necessary, what is a use case for them? (I dont want to clutter the namespace)
These can be useful when calculating some other CSS properties: for example, we have a sprite for social "share" buttons (for Facebook, Twitter, etc.) and the line-height
property for the each button should be equal to it's height
.
Now we can achieve this only using Sass nth
function:
.social-share.facebook{
...
// Assume that we set prefix to "share-buttons-"
line-height: nth( $share-buttons-facebook, 4 );
}
— it looks overkill for me — I don't like any sort of "magic numbers" in the code.
Also these variables can be used in third-party mixins for creating styles with sprite backgrounds ("sprite in sprite" case).
And the last use case — just to make this:
@include share-buttons-sprite-width( $share-buttons-facebook );
@include share-buttons-sprite-height( $share-buttons-facebook );
more shorter and clear:
width: $share-buttons-facebook-width;
height: $share-buttons-facebook-height;
(of course, in that case it is matter of taste, but I think someone would prefer to use these variables instead of mixins).
Sweet, thanks. I will need to implement the same stuff for the other preprocessor languages before I release a new version. :beers:
Sometimes it's necessary to include only some properties of the current sprite's mixin (
background-image
, for example).I added in the scss stylesheet template new mixins for
background-image
,background-size
,background-position
,width
andheight
, and included them in the main mixin. Also new variables were added for the each image in sprite. The output scss file now looks like this:I made it only for scss template, but I think that it also should be done for the sass, less and stylus.