From a254caecdd0139b3ba909679b260435de87733ef Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sun, 19 Dec 2010 17:57:33 -0800 Subject: [PATCH] Allow a prefix to be specified (or omitted) for sprite class names --- .../stylesheets/compass/utilities/sprites/_base.scss | 5 +++-- lib/compass/sprites.rb | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/frameworks/compass/stylesheets/compass/utilities/sprites/_base.scss b/frameworks/compass/stylesheets/compass/utilities/sprites/_base.scss index fc095761..bc749162 100644 --- a/frameworks/compass/stylesheets/compass/utilities/sprites/_base.scss +++ b/frameworks/compass/stylesheets/compass/utilities/sprites/_base.scss @@ -30,9 +30,10 @@ // If a base class is provided, then each class will extend it. // // 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 { - .#{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}; } @include sprite($map, $sprite-name, $dimensions); } diff --git a/lib/compass/sprites.rb b/lib/compass/sprites.rb index 2d5d0bf7..707d9bdb 100644 --- a/lib/compass/sprites.rb +++ b/lib/compass/sprites.rb @@ -88,13 +88,13 @@ end.join(",\n")}); @include sprite($#{name}-sprites, $name, $dimensions, $offset-x, $offset-y) } -@mixin #{name}-sprites($sprite-names, $dimensions: $#{name}-sprite-dimensions) { - @include sprites($#{name}-sprites, $sprite-names, $#{name}-sprite-base-class, $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, $prefix) } // Generates a class for each sprited image. -@mixin all-#{name}-sprites($dimensions: $#{name}-sprite-dimensions) { - @include #{name}-sprites(#{images.join(" ")}, $dimensions); +@mixin all-#{name}-sprites($dimensions: $#{name}-sprite-dimensions, $prefix: sprite-map-name($#{name}-sprites)) { + @include #{name}-sprites(#{images.join(" ")}, $dimensions, $prefix); } SCSS end