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

Commit

Permalink
Remove comments and add specs
Browse files Browse the repository at this point in the history
- Closes #140
  • Loading branch information
Reda Lemeden committed Feb 10, 2014
1 parent a9da0cf commit 410fd96
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
9 changes: 2 additions & 7 deletions app/assets/stylesheets/grid/_media.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
@mixin media($query:$feature $value $columns, $total-columns: $grid-columns) {

// if no arguments, give warning
@if length($query) == 1 {
@media screen and ($default-feature: nth($query, 1)) {
$default-grid-columns: $grid-columns;
Expand All @@ -9,16 +7,13 @@
$grid-columns: $default-grid-columns;
}
}

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

// if there is an odd number of parameters,
// the last one is the number of columns
// grab the value and assign it, then
// decrement the counter
@if length($query) % 2 != 0 {
$grid-columns: nth($query, $loopTo);
$loopTo: $loopTo - 1;
Expand All @@ -27,7 +22,7 @@
$i: 1;
@while $i <= $loopTo {
$mediaQuery: $mediaQuery + '(' + nth($query, $i) + ': ' + nth($query, $i + 1) + ') ';

@if ($i + 1) != $loopTo {
$mediaQuery: $mediaQuery + 'and ';
}
Expand Down
10 changes: 10 additions & 0 deletions spec/neat/media_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,14 @@
expect('.change-media-context-shorthand').to have_rule('width: 100%')
end
end

context "with composite argument (max-width 768px min-width 110px orientation portait 6)" do
it "outputs @media screen and (max-width: 768px) and (min-width: 110px) and (orientation: portait)" do
expect('.composite-media-query').to be_contained_in('screen and (max-width: 768px) and (min-width: 110px) and (orientation: portait)')
end

it "uses a 6-column grid" do
expect('.composite-media-query').to have_rule('width: 100%')
end
end
end
8 changes: 8 additions & 0 deletions test/media.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@import 'setup';

$composite: new-breakpoint(max-width 768px min-width 110px orientation portait 6);

.media-default {
@include media(481px) {
color: #000;
Expand Down Expand Up @@ -29,3 +31,9 @@
@include span-columns(6);
}
}

.composite-media-query {
@include media($composite) {
@include span-columns(6);
}
}

0 comments on commit 410fd96

Please sign in to comment.