// ----------------------------------------- // GRID // Based on ZURB's Foundation 4 // ----------------------------------------- $row-max-width : 1140px !default; $total-columns : 12 !default; $column-gutter : 20px !default; // Calculate percentages for grid @function gridCalc($colNumber, $totalColumns) { @return percentage($colNumber / $totalColumns); } // --------------------------------- // GRID ROW // Create container for the grid // --------------------------------- @mixin grid-row( $nest : false, $collapse : false, $width : $row-max-width, $gutter : $column-gutter, $for-base : false ) { @if $for-base { margin: 0 auto; width: 100%; max-width: $width + $gutter; @if not $responsive { min-width: $width + $gutter; } @include clearfix; } // If gutter is passed as param, calculate it @if $gutter != $column-gutter { max-width: $width + $gutter; @if not $responsive { min-width: $width + $gutter; } } @if $nest and $collapse { margin: 0; padding-right: 0; padding-left: 0; width: auto; max-width: none; @if not $responsive { min-width: 0; } } @else if $nest { margin-right: -($gutter / 2); margin-left: -($gutter / 2); width: auto; max-width: none; @if not $responsive { min-width: 0; } } @else if $collapse { margin: 0 auto; width: 100%; max-width: $width; @if not $responsive { min-width: $width; } } @if $external-call { .row & { margin-right: -($gutter / 2); margin-left: -($gutter / 2); } } } // ---------------------------------------------- // Calculate size for column created externally @mixin external-call-column( $column : 0, $total : 0, $offset : 0, $parent-offset : 0) { @if $column > 0 { width: gridCalc($column, $total); } @else { width: 100%; } // Offset is only allowed if the column is specified @if $column > 0 and $offset > 0 { margin-#{$default-float}: gridCalc($offset, $total); } // If parent (larger) column has offset, remove it @else if $parent-offset > 0 { margin-#{$default-float}: 0; } } // ---------------------------------- // Prevent duplicate in grid-column @mixin source-ordering-column( $push : 0, $pull : 0, $total : 0) { @if $push > 0 { #{$default-float}: gridCalc($push, $total); #{$default-opposite}: auto; } @if $pull > 0 { #{$default-opposite}: gridCalc($pull, $total); #{$default-float}: auto; } } // -------------------------------------- // Prevent duplicate in the base output @mixin source-ordering-output() { @for $i from 1 through $total-columns - 1 { .large-offset-#{$i} { @include grid-column($large-offset:$i); } .push#{-$i} { @include grid-column($push:$i); } .pull#{-$i} { @include grid-column($pull:$i); } } } // ------------------------ // GRID COLUMN // Create the grid // ------------------------ @mixin grid-column( $large : 0, $small : 0, // For external call only, small size screen $mini : 0, // For external call only, mini size screen $large-offset : 0, $small-offset : 0, // For external call only $mini-offset : 0, // For external call only $push : 0, $pull : 0, $collapse : false, $center : false, $gutter : $column-gutter, $total : $total-columns, $for-base : false ) { @if $for-base { position: relative; float: $default-float; padding-right: $gutter / 2; padding-left: $gutter / 2; } // If gutter's value is different from default, it means it is passed as param @if $gutter != $column-gutter { padding-right: $gutter / 2; padding-left: $gutter / 2; } // If collapsed, get rid of distance padding @if $collapse { padding-right: 0; padding-left: 0; } // If offset, calculate appropriate margins @if $large-offset > 0 { margin-#{$default-float}: gridCalc($large-offset, $total); } // If a column number is given, calculate width @if $large > 0 { width: gridCalc($large, $total); } // Source Ordering, adds left/right depending on which you use. @if $external-call and $responsive { @include above(small) { @include source-ordering-column($push:$push, $pull:$pull, $total:$total); } } @else { @include source-ordering-column($push:$push, $pull:$pull, $total:$total); } // If centered, get rid of float and add auto margin @if $center { display: block; float: none; margin-right: auto !important; margin-left: auto !important; } // If external call and responsive is true @if $external-call and $responsive { // If small column is specified @if $small > 0 { @include below(small) { @include external-call-column($column:$small, $total:$total, $offset:$small-offset, $parent-offset:$large-offset); } @if $mini > 0 { @include below(mini) { @include external-call-column($column:$mini, $total:$total, $offset:$mini-offset, $parent-offset:$small-offset); } } } // If small is not passed, stack the column @else { @include below(small) { @include external-call-column($column:$small, $total:$total, $offset:$small-offset, $parent-offset:$large-offset); } } } // Create notes when on debug @if $debug { $notes: "large-#{$large}"; @if $large-offset > 0 { $notes: $notes + " large-offset-#{$large-offset}"; } @if $small > 0 { $notes: $notes + " small-#{$small}"; } @if $small-offset > 0 { $notes: $notes + " small-offset-#{$small-offset}"; } @if $mini > 0 { $notes: $notes + " mini-#{$mini}"; } @if $mini-offset > 0 { $notes: $notes + " mini-offset-#{$mini-offset}"; } @if $push > 0 { $notes: $notes + " push-#{$push}"; } @if $pull > 0 { $notes: $notes + " pull-#{$pull}"; } @if $center { $notes: $notes + " centered"; } edge-column: $notes; } } @if $include-grid { /* --------------- EDGE Grid --------------- */ // Normal row .row { @include grid-row($for-base:true); // Collapsed row &.collapse { @include grid-row($collapse:true); .column, .columns { @include grid-column($collapse:true); } } // Nested-collapsed row .row { @include grid-row($nest:true); &.collapse { @include grid-row($nest:true, $collapse:true); } } } // Normal column .column, .columns { @include grid-column($large:$total-columns, $for-base:true); } @for $i from 1 through $total-columns { .large#{-$i} { @include grid-column($large:$i); } } // Centered column .column.large-centered, .columns.large-centered { @include grid-column($center:true); } // Source Ordering @if $responsive { @include above(small) { @include source-ordering-output(); } } @else { @include source-ordering-output(); } @if $responsive { // Small screen and below @include below(small) { .column, .columns { @include grid-column($large:$total-columns); } @for $i from 1 through $total-columns { .small#{-$i} { @include grid-column($large:$i); } } @for $i from 0 through $total-columns - 2 { .small-offset-#{$i} { @include grid-column($large-offset:$i); } } .column.small-centered, .columns.small-centered { @include grid-column($center:true); } } } // responsive } // $include-grid