Allow a prefix to be specified (or omitted) for sprite class names
This commit is contained in:
parent
df8eefa3c2
commit
a254caecdd
@ -30,9 +30,10 @@
|
|||||||
// If a base class is provided, then each class will extend it.
|
// If a base class is provided, then each class will extend it.
|
||||||
//
|
//
|
||||||
// If `$dimensions` is `true`, the sprite dimensions will specified.
|
// If `$dimensions` is `true`, the sprite dimensions will specified.
|
||||||
@mixin sprites($map, $sprite-names, $base-class: false, $dimensions: false) {
|
@mixin sprites($map, $sprite-names, $base-class: false, $dimensions: false, $prefix: sprite-map-name($map)) {
|
||||||
@each $sprite-name in $sprite-names {
|
@each $sprite-name in $sprite-names {
|
||||||
.#{sprite-map-name($map)}-#{$sprite-name} {
|
$full-sprite-name: if($prefix and $prefix != "", "#{$prefix}-#{$sprite-name}", $sprite-name);
|
||||||
|
.#{$full-sprite-name} {
|
||||||
@if $base-class { @extend #{$base-class}; }
|
@if $base-class { @extend #{$base-class}; }
|
||||||
@include sprite($map, $sprite-name, $dimensions);
|
@include sprite($map, $sprite-name, $dimensions);
|
||||||
}
|
}
|
||||||
|
@ -88,13 +88,13 @@ end.join(",\n")});
|
|||||||
@include sprite($#{name}-sprites, $name, $dimensions, $offset-x, $offset-y)
|
@include sprite($#{name}-sprites, $name, $dimensions, $offset-x, $offset-y)
|
||||||
}
|
}
|
||||||
|
|
||||||
@mixin #{name}-sprites($sprite-names, $dimensions: $#{name}-sprite-dimensions) {
|
@mixin #{name}-sprites($sprite-names, $dimensions: $#{name}-sprite-dimensions, $prefix: sprite-map-name($#{name}-sprites)) {
|
||||||
@include sprites($#{name}-sprites, $sprite-names, $#{name}-sprite-base-class, $dimensions)
|
@include sprites($#{name}-sprites, $sprite-names, $#{name}-sprite-base-class, $dimensions, $prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generates a class for each sprited image.
|
// Generates a class for each sprited image.
|
||||||
@mixin all-#{name}-sprites($dimensions: $#{name}-sprite-dimensions) {
|
@mixin all-#{name}-sprites($dimensions: $#{name}-sprite-dimensions, $prefix: sprite-map-name($#{name}-sprites)) {
|
||||||
@include #{name}-sprites(#{images.join(" ")}, $dimensions);
|
@include #{name}-sprites(#{images.join(" ")}, $dimensions, $prefix);
|
||||||
}
|
}
|
||||||
SCSS
|
SCSS
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user