Open
Description
Now we need use bigger images for Retina like displays and resize images by background-size
. But current sprite API don’t allow us to use retina images in sprite.
I can add this feature to Compass, but I don’t sure in API. I think about something like:
$icons: sprite-map("icons/*.png", scale-factor: 2)
.add
+sized-sprite($icons, add)
or without shortcut:
$icons: sprite-map("icons/*.png", scale-factor: 2)
.add
width: image-width(sprite-file($icons, add))
height: image-height(sprite-file($icons, add))
background: sprite($icons, add) no-repeat
background-size: sprite-map-size($icons);
Which will compile to:
.add {
/* Real size of icons/add.png is 40×40 */
width: 20px;
height: 20px;
/* Real position is 0 20px, but we need to decrease it, because of background-size */
background: url(/images/icons-8754a4545656.png) 0 10px no-repeat;
/* Real width of sprite map is 40×200 */
background-size: 20px 100px;
}
I don’t know what we can do with another sprite APIs, like:
@import "my-icons/*.png"
+all-my-icons-sprites
Maybe nothing, as I understand this API can have options.
Also I think about mixin name: sized-sprite
or sprite-with-size
.
Anyway, I think, that this mixin is very useful without Retina support too. I always set image size to sprite block.
If idea and API (and extra sized-sprite
mixin) is good, I will start development.