// 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
$sprite-dash-case: (
  name: 'sprite-dash-case',
  x: 0px,
  y: 0px,
  offset-x: 0px,
  offset-y: 0px,
  width: 10px,
  height: 20px,
  total-width: 80px,
  total-height: 100px,
  image: 'nested/dir/spritesheet.png'
);
$sprite-snake-case: (
  name: 'sprite_snake_case',
  x: 10px,
  y: 20px,
  offset-x: -10px,
  offset-y: -20px,
  width: 20px,
  height: 30px,
  total-width: 80px,
  total-height: 100px,
  image: 'nested/dir/spritesheet.png'
);
$sprite-camel-case: (
  name: 'spriteCamelCase',
  x: 30px,
  y: 50px,
  offset-x: -30px,
  offset-y: -50px,
  width: 50px,
  height: 50px,
  total-width: 80px,
  total-height: 100px,
  image: 'nested/dir/spritesheet.png'
);
$spritesheet: (
  width: 80px,
  height: 100px,
  image: 'nested/dir/spritesheet.png',
  sprites: ($sprite-dash-case, $sprite-snake-case, $sprite-camel-case, )
);

// 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:
// <div class="icon-home"></div>
//
// To change `display` (e.g. `display: inline-block;`), we suggest using a common CSS class:
//
// // CSS
// .icon {
//   display: inline-block;
// }
//
// // HTML
// <i class="icon icon-home"></i>
@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);
    }
  }
}
