@spiriit/vite-plugin-svg-spritemap
Version:
Generates symbol-based SVG spritemap from all .svg files in a directory
28 lines (24 loc) • 673 B
text/less
.__mixin__(@name, @include-size: false, @type: 'uri', @route: '__route__') {
@sprite: @__sprites__[ @@name];
@fragment: if(
@type = 'fragment',
'/@{route}#@{__prefix__}@{name}-view',
false
);
@uri: if(@type = 'uri', @sprite[uri], false);
& when (isstring(@fragment)) {
background: url(@fragment) center no-repeat;
}
& when (isstring(@uri)) {
background: url(@uri) center no-repeat;
}
& when (isstring(@fragment)), (isstring(@uri)) {
& when (@include-size) {
background-size: @sprite[width] @sprite[height];
}
& when (@include-size = 'box') {
width: @sprite[width];
height: @sprite[height];
}
}
}