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

Commit

Permalink
Make shift() reset nesting context
Browse files Browse the repository at this point in the history
  • Loading branch information
Reda Lemeden committed Feb 18, 2013
1 parent ec1a5e8 commit cd75f3a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/assets/stylesheets/grid/_grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ $container-display-table: false;
// Shift
@mixin shift($n-columns: 1) {
margin-left: $n-columns * flex-grid(1, $parent-columns) + $n-columns * flex-gutter($parent-columns);

// Reset nesting context
$parent-columns: $grid-columns;
}


Expand Down
10 changes: 10 additions & 0 deletions spec/neat/shift_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,14 @@
expect('.shift-negative').to have_rule('margin-left: -25.58941%')
end
end

context "when nested" do
it "shifts element relative to its parent" do
expect('.shifted-parent .shifted-child').to have_rule('margin-left: 34.94305%')
end

it "resets nesting context" do
expect('.post-nested-shift').to have_rule('margin-left: 17.05961%')
end
end
end
14 changes: 14 additions & 0 deletions test/shift.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,17 @@
.shift-negative {
@include shift(-3);
}

// Nesting
.shifted-parent {
@include span-columns(6);

.shifted-child {
@include span-columns(2 of 6);
@include shift(2);
}
}

.post-nested-shift {
@include shift(2);
}

0 comments on commit cd75f3a

Please sign in to comment.