// SCSS variables are information about icon's compiled state, stored under its original file name // // .icon-home { // width: map-get($icon-home, 'width'); // } // // At the bottom of this section, we provide information about the spritesheet itself $nvs-logo: ( name: 'nvs-logo', x: 0px, y: 0px, offset-x: 0px, offset-y: 0px, width: 13px, height: 18px, total-width: 13px, total-height: 18px, image: '../../../dist/images/sprite.png' ); $spritesheet: ( width: 13px, height: 18px, image: '../../../dist/images/sprite.png', sprites: ($nvs-logo, ) ); // The provided mixins are intended to be used with variables directly // // .icon-home { // @include sprite-width($icon-home); // } // // .icon-email { // @include sprite($icon-email); // } // // Example usage in HTML: // // `display: block` sprite: //
// // To change `display` (e.g. `display: inline-block;`), we suggest using a common CSS class: // // // CSS // .icon { // display: inline-block; // } // // // HTML // @mixin sprite-width($sprite) { width: map-get($sprite, 'width'); } @mixin sprite-height($sprite) { height: map-get($sprite, 'height'); } @mixin sprite-position($sprite) { background-position: map-get($sprite, 'offset-x') map-get($sprite, 'offset-y'); } @mixin sprite-image($sprite) { background-image: url(map-get($sprite, 'image')); } @mixin sprite($sprite) { @include sprite-image($sprite); @include sprite-position($sprite); @include sprite-width($sprite); @include sprite-height($sprite); } // The `sprites` mixin generates identical output to the CSS template // but can be overridden inside of SCSS // // @include sprites(map-get($spritesheet, 'sprites')); @mixin sprites($sprites) { @each $sprite in $sprites { $sprite-name: map-get($sprite, 'name'); .#{$sprite-name} { @include sprite($sprite); } } }