Sha256: abad5a836c83d895844e7acb75d463b932e6b5df997d659d584dfa259a65594a

Contents?: true

Size: 1.43 KB

Versions: 11

Compression:

Stored size: 1.43 KB

Contents

//////////////////////////////
// Draw triangles
//////////////////////////////

@mixin triangle($color: #000, $height: 1em, $width: 1em, $angle: 0) {
  
  @if unit($height) == "" or unit($height) == "%" {
    @debug "in triangle #{$height} is not a compatable unit for height."
  }

  @if unit($width) == "" or unit($width) == "%" {
    @debug "in triangle #{$width} is not a compatable unit for width."
  }

  // offset 45deg to make each side start at 0
  $deg: $angle + 45;
  // if units, remove units
  @if unit($deg) == deg {
    $deg: $deg / 1deg;
  }
  // shift to be on a scale from 0 to 90.
  @while $deg > 90 {
    $deg: $deg - 90;
  }
  @while $deg < 0 {
    $deg: $deg + 90;
  }
  // Get a ratio of 90 to multiply by.
  $deg: $deg / 90;

  // make sure metrics are reset
  display: block;
  width: 0;
  height: 0;
  border: 0 solid transparent;

  // run through sides
  @if $angle <= 45 or $angle > 315 {
    border-bottom-color: $color;
    border-width: 0 ($width * abs($deg - 1)) $height ($width * $deg);
  }
  @if $angle > 45 and $angle <= 135 {
    border-left-color: $color;
    border-width: ($height * $deg) 0 ($height * abs($deg - 1)) $width;
  }
  @if $angle > 135 and $angle <= 225 {
    border-top-color: $color;
    border-width: $height ($width * $deg) 0 ($width * abs($deg - 1));
  }
  @if $angle > 225 and $angle <= 315 {
    border-right-color: $color;
    border-width: ($height * abs($deg - 1)) $width ($height * $deg) 0;
  }
}

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
toolkit-1.2.1 stylesheets/toolkit/_triangle.scss
toolkit-1.1.1 stylesheets/toolkit/_triangle.scss
toolkit-1.1.0 stylesheets/toolkit/_triangle.scss
toolkit-1.0.0 stylesheets/toolkit/_triangle.scss
toolkit-0.3.1 stylesheets/toolkit/_triangle.scss
toolkit-0.3.0 stylesheets/toolkit/_triangle.scss
toolkit-0.2.8 stylesheets/toolkit/_triangle.scss
toolkit-0.2.7 stylesheets/toolkit/_triangle.scss
toolkit-0.2.6 stylesheets/toolkit/_triangle.scss
toolkit-0.2.5 stylesheets/toolkit/_triangle.scss
toolkit-0.2.4 stylesheets/toolkit/_triangle.scss