_private.scss 2.59 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
// Checks if a number is even
@function is-even($int) {
  @if $int%2 == 0   {
    @return true;
  }

  @return false;
}

// Checks if an element belongs to a list
@function belongs-to($tested-item, $list) {
  @each $item in $list {
    @if $item == $tested-item {
      @return true;
    }
  }

  @return false;
}

// Contains display value
@function contains-display-value($query) {
  @if belongs-to(table, $query) or belongs-to(block, $query) or belongs-to(inline-block, $query) or belongs-to(inline, $query) {
    @return true;
  }

  @return false;
}

// Parses the first argument of span-columns()
@function container-span($span: $span) {
  @if length($span) == 3 {
    $container-columns: nth($span, 3);
    @return $container-columns;
  }

  @else if length($span) == 2 {
    $container-columns: nth($span, 2);
    @return $container-columns;
  }

  @else {
    @return $grid-columns;
  }
}

47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
@function container-shift($shift: $shift) {
  $parent-columns: $grid-columns !global !default;

  @if length($shift) == 3 {
    $container-columns: nth($shift, 3);
    @return $container-columns;
  }

  @else if length($shift) == 2 {
    $container-columns: nth($shift, 2);
    @return $container-columns;
  }

  @else {
    @return $parent-columns;
  }
}

65 66
// Generates a striped background
@function gradient-stops($grid-columns, $color: $visual-grid-color) {
67
  $transparent: $transparent;
68 69 70 71 72 73 74 75 76

  $column-width: flex-grid(1, $grid-columns);
  $gutter-width: flex-gutter($grid-columns);
  $column-offset: $column-width;

  $values: ($transparent 0, $color 0);

  @for $i from 1 to $grid-columns*2 {
    @if is-even($i) {
77 78
      $values: append($values, $transparent $column-offset, comma);
      $values: append($values, $color $column-offset, comma);
79 80 81 82
      $column-offset: $column-offset + $column-width;
    }

    @else {
83 84
      $values: append($values, $color $column-offset, comma);
      $values: append($values, $transparent $column-offset, comma);
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
      $column-offset: $column-offset + $gutter-width;
    }
  }

  @return $values;
}

// Layout direction
@function get-direction($layout, $default) {
  $direction: nil;
  
  @if $layout == LTR or $layout == RTL {
    $direction: direction-from-layout($layout);
  } @else {
    $direction: direction-from-layout($default);
  }

  @return $direction;
}

@function direction-from-layout($layout) {
  $direction: nil;

  @if $layout == LTR {
    $direction: right;
  } @else {
    $direction: left;
  }

  @return $direction;
}

@function get-opposite-direction($direction) {
  $opposite-direction: left;

  @if $direction == left {
    $opposite-direction: right;
  }

  @return $opposite-direction;
}