Permalink
Browse files

Make shift() reset nesting context

  • Loading branch information...
1 parent ec1a5e8 commit cd75f3abe24e3191c4f88e93f953650ea6e079c9 Reda Lemeden committed Feb 18, 2013
Showing with 27 additions and 0 deletions.
  1. +3 −0 app/assets/stylesheets/grid/_grid.scss
  2. +10 −0 spec/neat/shift_spec.rb
  3. +14 −0 test/shift.scss
@@ -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;
}
View
@@ -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
View
@@ -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.