// SVG-Sprites
$timestamp: #{unix_timestamp()};

// same use instructions as sprite-position()
// $map is the sprite-map generated through svg-sprite
@function svg-sprite-get($map, $sprite) {
  @each $s in nth($map, 2) {
    $s-name: nth($s, 1);
    @if $s-name == $sprite {
      @return $s;
    }
  }
}

@function svg-position($map, $sprite, $offset-x: 0, $offset-y: 0) {
  $s: svg-sprite-get($map, $sprite);
  $s-position-x: nth($s, 2);
  $s-position-y: nth($s, 3);

  @return round($s-position-x + $offset-x) round($s-position-y + $offset-y);
}

@function svg-url($map) {
  // This is something you'll probably want to customize
  @return unquote("url(") + nth($map, 1) + unquote("?") + $timestamp + unquote(")");
}

@function svg-width($map, $sprite) {
  $s: svg-sprite-get($map, $sprite);

  @return nth($s, 4);
}

@function svg-height($map, $sprite) {
  $s: svg-sprite-get($map, $sprite);

  @return nth($s, 5);
}

@mixin svg-sprite($imgname) {
  background-image: svg-url($svg-sprite__icons);
  background-position: svg-position($svg-sprite__icons, $imgname);
}

@mixin svg_element($imgname) {
  @include svg-sprite($imgname);

  width: svg-width($svg-sprite__icons, $imgname);
  height: svg-height($svg-sprite__icons, $imgname);
}

@mixin svgpseudoelem($imgname: false) {
  content: "";
  position: absolute;
  display: inline-block;
  left: 0;

  @include svg_element($imgname);
}