Git Product home page Git Product logo

lemonade's Introduction

Lemonade—On the fly sprite generator for Sass/Compass

Please read my blog post on CSS sprites for Sass/Compass or have a look at the presentation 3 steps to make better and faster frontends (slides 23—37).

Usage (SCSS or Sass):

.fanta {
  background: sprite-image("bottles/fanta.png");
}
.seven-up {
  background: sprite-image("bottles/seven-up.png");
}
.coke {
  background: sprite-image("cans/coke.png") no-repeat;
}

Output (CSS):

.fanta {
  background: url('/images/bottles.png');
}
.seven-up {
  background: url('/images/bottles.png') 0 -50px;
}
.coke {
  background: url('/images/cans.png') no-repeat;
}

Background

  • Generates a sprite image for each folder (e. g. “bottles” and “cans”)
  • Sets the background position (unless “0 0”)
  • It uses the images_dir defined by Compass (just like image-url())
  • No Rake task needed
  • No additional classes
  • No configuration
  • No RMagick required (but full support for PNG)

Installation

gem install lemonade

Current State

  • Compass standalone finished
  • Rails Sass integration finished
  • Staticmatic integration finished
  • Haml integration (with “:sass” filter): work in progress

Options

You can pass an additional background position. It will be added to the calculated position:

.seven-up {
  background: sprite-image("bottles/seven-up.png", 12px, 3px);
}

Output (assuming the calculated position would be “0 -50px” as shown above):

.seven-up {
  background: url('/images/bottles.png') 12px -47px;
}

If you need empty space around the current image, this will add 20px transparent space above and below.

.seven-up {
  background: sprite-image("bottles/seven-up.png", 0, 0, 20px);
}

This one adds 20px above, 30px below:

.seven-up {
  background: sprite-image("bottles/seven-up.png", 0, 0, 20px, 30px);
}

Right aligned images are possible:

.seven-up {
  background: sprite-image("bottles/seven-up.png", 100%, 4px);
}

The original image will be placed on the right side of the sprite image. Use this, if you have a link with an arrow on the right side (like Apple).

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Rails 3 Troubleshooting

If you want to use Lemonade with Rails 3 Please use this compass and haml versions in your Gemfile

gem 'compass',     '0.10.2'
gem 'haml-edge',   '3.1.49', :require => 'haml'

Copyright

Copyright (c) 2010 Nico Hagenburger. See MIT-LICENSE for details. Follow me on twitter.

lemonade's People

Contributors

hagenburger avatar sebastiandeutsch avatar

Stargazers

Mattias Pfeiffer avatar

Watchers

Mattias Pfeiffer avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.