added default spacing

This commit is contained in:
Nico Hagenburger 2010-10-17 15:44:29 +02:00 committed by Chris Eppstein
parent bf47c74dc2
commit c62b8e718d
2 changed files with 23 additions and 1 deletions

View File

@ -4,11 +4,12 @@ module Compass::SassExtensions::Functions::Sprites
path, name = Compass::Sprites.path_and_name(uri)
y = 0
last_spacing = 0
default_spacing = number_from_var("#{name}-spacing")
images = Compass::Sprites.sprites(name)
images.each do |image|
current_spacing = number_from_var("#{name}-#{image[:name]}-spacing")
if y > 0
y += current_spacing > last_spacing ? current_spacing : last_spacing
y += [current_spacing, last_spacing, default_spacing].max
end
image[:y] = y
y += image[:height]

View File

@ -196,5 +196,26 @@ describe Compass::Sprites do
}
CSS
end
it "should calculate the default spacing between images" do
css = render <<-SCSS
$squares-spacing: 22px;
@import "squares/*.png";
@include all-squares-sprites;
SCSS
css.should == <<-CSS
.squares-sprite, .squares-10x10, .squares-20x20 {
background: url('/squares.png') no-repeat;
}
.squares-10x10 {
background-position: 0 0;
}
.squares-20x20 {
background-position: 0 -32px;
}
CSS
end
end