Merge remote-tracking branch 'origin/master'
* origin/master: Add a test for the new sprite offset passing. Pass through offset parameters to the :hover, :target, and :active magic sprite selectors.
This commit is contained in:
commit
f89f3839dc
@ -30,18 +30,18 @@ $disable-magic-sprite-selectors:false !default;
|
||||
@include sprite-dimensions($map, $sprite);
|
||||
}
|
||||
@if not $disable-magic-sprite-selectors {
|
||||
@include sprite-selectors($map, $sprite, $sprite);
|
||||
@include sprite-selectors($map, $sprite, $sprite, $offset-x, $offset-y);
|
||||
}
|
||||
}
|
||||
|
||||
// Include the selectors for the `$sprite` given the `$map` and the
|
||||
// `$full-sprite-name`
|
||||
// @private
|
||||
@mixin sprite-selectors($map, $sprite-name, $full-sprite-name) {
|
||||
@mixin sprite-selectors($map, $sprite-name, $full-sprite-name, $offset-x: 0, $offset-y: 0) {
|
||||
@each $selector in $sprite-selectors {
|
||||
@if sprite_has_selector($map, $sprite-name, $selector) {
|
||||
&:#{$selector}, &.#{$full-sprite-name}_#{$selector}, &.#{$full-sprite-name}-#{$selector} {
|
||||
@include sprite-background-position($map, "#{$sprite-name}_#{$selector}");
|
||||
@include sprite-background-position($map, "#{$sprite-name}_#{$selector}", $offset-x, $offset-y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -519,6 +519,33 @@ class SpritesTest < Test::Unit::TestCase
|
||||
CSS
|
||||
end
|
||||
|
||||
it "should render corret sprite with css selectors via magic mixin with the correct offsets" do
|
||||
css = render <<-SCSS
|
||||
@import "selectors/*.png";
|
||||
a {
|
||||
@include selectors-sprite(ten-by-ten, false, 5, -5)
|
||||
}
|
||||
SCSS
|
||||
assert_correct css, <<-CSS
|
||||
.selectors-sprite, a {
|
||||
background: url('/selectors-sedfef809e2.png') no-repeat;
|
||||
}
|
||||
|
||||
a {
|
||||
background-position: 5px -5px;
|
||||
}
|
||||
a:hover, a.ten-by-ten_hover, a.ten-by-ten-hover {
|
||||
background-position: 5px -25px;
|
||||
}
|
||||
a:target, a.ten-by-ten_target, a.ten-by-ten-target {
|
||||
background-position: 5px -35px;
|
||||
}
|
||||
a:active, a.ten-by-ten_active, a.ten-by-ten-active {
|
||||
background-position: 5px -15px;
|
||||
}
|
||||
CSS
|
||||
end
|
||||
|
||||
it "should raise error on filenames that are not valid sass syntax" do
|
||||
assert_raise(Compass::Error) do
|
||||
css = render <<-SCSS
|
||||
|
Loading…
Reference in New Issue
Block a user