Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Commit

Permalink
Refactor private functions
Browse files Browse the repository at this point in the history
    - Closes #243
    - Use null instead of nil (closes #234)
    - Ignore case for string variables (closes #235)
    - Remove extraneous @else (closes #237)
    - Use is-even where appropriate (closes #238)
    - Remove ternaries (closes #239)
    - Remove camel case (closes #240)
    - Refactor is-display-table (closes #241)
  • Loading branch information
Reda Lemeden committed Oct 3, 2014
1 parent 3d2be9f commit 2875ee2
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 47 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/functions/_new-breakpoint.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$query: $default-feature nth($query, 1) $total-columns;
}

@else if length($query) % 2 == 0 {
@else if is-even(length($query)) {
$query: append($query, $total-columns);
}

Expand Down
30 changes: 10 additions & 20 deletions app/assets/stylesheets/functions/_private.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@
@if length($span) == 3 {
$container-columns: nth($span, 3);
@return $container-columns;
}

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

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

@function container-shift($shift: $shift) {
Expand All @@ -43,16 +39,12 @@
@if length($shift) == 3 {
$container-columns: nth($shift, 3);
@return $container-columns;
}

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

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

// Generates a striped background
Expand All @@ -70,9 +62,7 @@
$values: append($values, $transparent $column-offset, comma);
$values: append($values, $color $column-offset, comma);
$column-offset: $column-offset + $column-width;
}

@else {
} @else {
$values: append($values, $color $column-offset, comma);
$values: append($values, $transparent $column-offset, comma);
$column-offset: $column-offset + $gutter-width;
Expand All @@ -84,9 +74,9 @@

// Layout direction
@function get-direction($layout, $default) {
$direction: nil;
$direction: null;

@if $layout == LTR or $layout == RTL {
@if to-upper-case($layout) == "LTR" or to-upper-case($layout) == "RTL" {
$direction: direction-from-layout($layout);
} @else {
$direction: direction-from-layout($default);
Expand All @@ -96,9 +86,9 @@
}

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

@if $layout == LTR {
@if to-upper-case($layout) == "LTR" {
$direction: right;
} @else {
$direction: left;
Expand All @@ -110,7 +100,7 @@
@function get-opposite-direction($direction) {
$opposite-direction: left;

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

Expand Down
4 changes: 2 additions & 2 deletions app/assets/stylesheets/grid/_direction.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
@mixin direction($direction: left-to-right) {
$scope-direction: $layout-direction;

@if $direction == left-to-right {
@if to-lower-case($direction) == "left-to-right" {
$layout-direction: LTR !global;
} @else if $direction == right-to-left {
} @else if to-lower-case($direction) == "right-to-left" {
$layout-direction: RTL !global;
}

Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/grid/_display.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
@mixin display($display: block) {
$scope-display: $container-display-table;
$container-display-table: if($display == table, true, false) !global;
$container-display-table: $display == table !global;

@content;

Expand Down
20 changes: 10 additions & 10 deletions app/assets/stylesheets/grid/_media.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,28 @@
}

@else {
$loopTo: length($query);
$mediaQuery: 'screen and ';
$loop-to: length($query);
$media-query: 'screen and ';
$default-grid-columns: $grid-columns;
$grid-columns: $total-columns !global;

@if length($query) % 2 != 0 {
$grid-columns: nth($query, $loopTo) !global;
$loopTo: $loopTo - 1;
@if not is-even(length($query)) {
$grid-columns: nth($query, $loop-to) !global;
$loop-to: $loop-to - 1;
}

$i: 1;
@while $i <= $loopTo {
$mediaQuery: $mediaQuery + '(' + nth($query, $i) + ': ' + nth($query, $i + 1) + ') ';
@while $i <= $loop-to {
$media-query: $media-query + '(' + nth($query, $i) + ': ' + nth($query, $i + 1) + ') ';

@if ($i + 1) != $loopTo {
$mediaQuery: $mediaQuery + 'and ';
@if ($i + 1) != $loop-to {
$media-query: $media-query + 'and ';
}

$i: $i + 2;
}

@media #{$mediaQuery} {
@media #{$media-query} {
@content;
$grid-columns: $default-grid-columns !global;
}
Expand Down
4 changes: 2 additions & 2 deletions app/assets/stylesheets/grid/_omega.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
* }
*/
@mixin omega($query: block, $direction: default) {
$table: if(belongs-to(table, $query), true, false);
$auto: if(belongs-to(auto, $query), true, false);
$table: belongs-to(table, $query);
$auto: belongs-to(auto, $query);

@if $direction != default {
@include -neat-warn("The omega mixin will no longer take a $direction argument. To change the layout direction, use the direction(){...} mixin.");
Expand Down
12 changes: 2 additions & 10 deletions app/assets/stylesheets/grid/_private.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $fg-column: $column;
$fg-gutter: $gutter;
$fg-max-columns: $grid-columns;
$container-display-table: false !default;
$layout-direction: nil !default;
$layout-direction: LTR !default;

@function flex-grid($columns, $container-columns: $fg-max-columns) {
$width: $columns * $fg-column + ($columns - 1) * $fg-gutter;
Expand Down Expand Up @@ -31,13 +31,5 @@ $layout-direction: nil !default;
}

@function is-display-table($container-is-display-table, $display) {
$display-table: false;

@if $container-is-display-table == true {
$display-table: true;
} @else if $display == table {
$display-table: true;
}

@return $display-table;
@return $container-is-display-table == true or $display == table;
}
2 changes: 1 addition & 1 deletion app/assets/stylesheets/grid/_visual-grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}

@each $breakpoint in $visual-grid-breakpoints {
@if $breakpoint != nil {
@if $breakpoint {
@include media($breakpoint) {
@include grid-column-gradient(gradient-stops($grid-columns));
}
Expand Down

0 comments on commit 2875ee2

Please sign in to comment.