//////////////////////////////
// Triangle
//
// Creates an SVG triangle
// @param {Color} $fill - Fill color
// @param {Color} $stroke - Stroke color
// @param {Number} $stroke-width - Width of the stroke
// @param {Number} $stroke-miter - Miter Limit of stroke
// @param {Number} $size - The size of the triangle
// @param {String} - $direction - Direction the arrow is pointing. Can be one of `up`, `down`, `left`, `right`
// @param {Boolean} - $encode - Whether or not to encode string
// @return {String} - Updated string
//
// Dependencies: `svg`
//////////////////////////////

@function triangle($fill: null, $stroke: null, $stroke-width: null, $stroke-miter: null, $size: 1, $direction: 'down', $encode: true) {
  $triangle: '<polygon';

  @if $fill {
    $triangle: $triangle + ' fill="#{$fill}"';
  }

  @if $stroke {
    $triangle: $triangle + ' stroke="#{$stroke}"';
  }

  @if $stroke-width {
    $triangle: $triangle + ' stroke-width="#{$stroke-width}"';
  }

  @if $stroke-miter {
    $triangle: $triangle + ' stroke-miterlimit="#{$stroke-miter}"';
  }

  @if $direction == 'up' {
    $triangle: $triangle + ' points="#{8 * $size},#{8 * $size} #{4.1 * $size},0 0,#{8 * $size} "';
  } @else if $direction == 'left' {
    $triangle: $triangle + ' points="#{8 * $size},0 0,#{3.9 * $size} #{8 * $size},#{8 * $size} "';
  } @else if $direction == 'right' {
    $triangle: $triangle + ' points="0,#{8 * $size} #{8 * $size},#{4.1 * $size} 0,0 "';
  } @else {
    $triangle: $triangle + ' points="0,0 #{3.9 * $size},#{8 * $size} #{8 * $size},0 "';
  }


  $triangle: $triangle + '/>';

  @return svg($triangle, '0 0 #{8 * $size} #{8 * $size}' $encode);
}
