Sha256: a17e4347feec5b683043d16ba63dd65c1b4b2abf1186b5cd320a0a3c1f7f1b15

Contents?: true

Size: 1.57 KB

Versions: 5

Compression:

Stored size: 1.57 KB

Contents

// 16 arguments can be passed into this function
// a max of 16 comma seperated grids
@function compound($cg1: 1, $cg2: 1, $cg3: 1, $cg4: 1, $cg5: 1, $cg6: 1, $cg7: 1, $cg8: 1, $cg9: 1, $cg10: 1, $cg11: 1, $cg12: 1, $cg13: 1, $cg14: 1, $cg15: 1, $cg16: 1) {

  // merge arguments into a single list.
  $compound-grids: $cg1, $cg2, $cg3, $cg4, $cg5, $cg6, $cg7, $cg8, $cg9, $cg10, $cg11, $cg12, $cg13, $cg14, $cg15, $cg16;

  // Find the base resolution of grid
  $resolution: 1;
  @each $item in $compound-grids {
    $resolution: $resolution * $item;
  }

  $compound-grid: ();
  $compound-counter: 1;
  // cycle through each step in grid resolution
  @for $i from 1 through $resolution {

    // dont add a column by default
    $add-col: false;

    // cycle through all grids to see if any grids match
    @each $grid in $compound-grids {

      // if the grid divides evenly into the resolution, add a column
      // divide the resolution by number of columns to get the column resolution
      @if $i / ($resolution / $grid) == round($i / ($resolution / $grid)) {
        $add-col: true;
      }
    }

    // add the counter value to the compound grid list, reset counter
    // this marks where one column ends and a new one begins
    @if $add-col {
      $compound-grid: join($compound-grid, $compound-counter, comma);
      $compound-counter: 1;
    }
    // if no column is added, bump up counter
    @else {
      $compound-counter: $compound-counter + 1;
    }
  }

  @if $singularity-debug {
    @debug "Grid compounded to #{length($compound-grid)} columns";
  }

  @return $compound-grid;
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
singularitygs-1.0.alpha.2 stylesheets/singularitygs/grid-plugins/_compound.scss
singularitygs-1.0.alpha.1 stylesheets/singularitygs/grid-plugins/_compound.scss
singularitygs-1.0.alpha.0 stylesheets/singularitygs/grid-plugins/_compound.scss
singularitygs-0.0.17 stylesheets/singularitygs/grid-plugins/_compound.scss
singularitygs-0.0.16 stylesheets/singularitygs/grid-plugins/_compound.scss