rsrsss/xquery/build_sprites_css.xqy

20 lines
699 B
Plaintext

xquery version "3.0" encoding "utf-8";
let $sprites :=
for $file in file:children(file:resolve-path("./img/sprites/"))
where ends-with($file, ".png")
order by $file
return concat(".icon-", substring-before(file:name($file), ".png"))
return concat(
(: Styles that apply to all icons at once :)
string-join($sprites, ", "),
" { display: inline-block; position: relative; top: 4px; margin-right: 2px; background-image: url(../img/sprites.png); width: 16px; height: 16px; }",
(: Add an offset for the position of each sprite within the image :)
string-join(
for $sprite in $sprites
count $i
return concat($sprite, " { background-position: ", -($i - 1)*16, "px; }")
)
)