glittergallery/GlitterGallery

View on GitHub
app/assets/stylesheets/jeet/_functions.scss

Summary

Maintainability
Test Coverage
// List functions courtesy of the wonderful folks at Team Sass - check out their awesome grid: Singularity
@function -get_span($ratio: 1) {
  @return $ratio * 100;
}
@function -get_column($ratios: 1, $g: $jeet-gutter) {
  @if ($jeet-parent-first != 'true') {
    $ratios: -reverse($ratios);
  }
  $w: 100;
  @each $ratio in $ratios {
    $g: $g / $w * 100;
    $w: 100 * $ratio - $g + $ratio * $g;
  }
  @return $w $g;
}
@function -get_layout_direction() {
  $result: '';
  @if $jeet-layout-direction == RTL {
    $result: right;
  } @else {
    $result: left;
  }
  @return $result;
}
@function -replace-nth($list, $index, $value) {
  @if type-of($index) != number or $index == 0 or abs($index) > length($list) {
    @warn "Invalid index (#{$index}) for `replace-nth`.";
    @return false;
  }
  $list: set-nth($list, $index, $value);
  @return if(not is-true($value), purge($list), $list);
}
@function -reverse($list, $recursive: false) {
  $result: ();
  @for $i from length($list)*-1 through -1 {
    @if type-of(nth($list, abs($i))) == list and $recursive {
      $result: append($result, reverse(nth($list, abs($i)), $recursive));
    } @else {
      $result: append($result, nth($list, abs($i)));
    }
  }
  @return $result;
}
@function opposite-direction($dir) {
  @if $dir == 'left' {
    @return right;
  }
  @else if  $dir == 'right' {
    @return left;
  }
  @else if $dir == 'ltr' {
    @return rtl;
  }
  @else if $dir == 'rtl' {
    @return ltr;
  }
  @else if $dir == 'top' {
    @return bottom;
  }
  @else if $dir == 'bottom' {
    @return top;
  }
  @else {
    @warn "#{$dir} is not a direction! Make sure your direction is all lowercase!";
    @return false;
  }
}