Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. $bem-blocks: (
  2. "foo",
  3. "bar",
  4. "baz"
  5. );
  6.  
  7. $sprite-files: ();
  8.  
  9. /*
  10. * Generate BEM-style silent classes for BEM sprites
  11. *
  12. * sprites/foo/
  13. * bar-baz.png
  14. * qux.png
  15. *
  16. * Generates: %foo-sprites__bar-baz and %foo-sprites__qux
  17. * Provides: width, height and background: <url> <position> no-repeat.
  18. */
  19. @each $block in $bem-blocks {
  20.  
  21. @if str-index($block, "_") {
  22. @error "BEM sprite blocks must be dasherized.";
  23. }
  24.  
  25. %#{$block}-sprites {
  26.  
  27. $map: sprite-map("sprites/#{$block}/*.png", $spacing: 10px);
  28.  
  29. // cache sprite-url, because it slows down compass compile
  30. $url: sprite-url($map);
  31.  
  32. @each $name in sprite-names($map) {
  33.  
  34. @if str-index($name, "_") {
  35. @error "BEM sprite files must be dasherized.";
  36. }
  37.  
  38. $sprite-files: map-merge($sprite-files, (
  39. #{$block}-sprite__#{$name}: sprite-file($map, #{$name})
  40. ));
  41.  
  42. &__#{$name} {
  43. background: $url sprite-position($map, $name) no-repeat;
  44. @include sprite-dimensions($map, $name);
  45. }
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement