Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/restorando/sprite-up

Sprite up!
https://github.com/restorando/sprite-up

Last synced: about 1 month ago
JSON representation

Sprite up!

Awesome Lists containing this project

README

        

# Sprite-Up

Take the pain away from spriting! With the fruitiness of this refreshing tropical mixin.
Sprite Up is a very simple tool to generate sprites for both retina and non-retina displays.

## Installation

1. You have two options:

a. Install Sprite-Up using [Bower](http://bower.io):

```bash
bower install sprite-up
```

b. Or, you can install Sprite-Up using [Rails Assets](https://rails-assets.org) (Only for [Bundler](http://bundler.io) >= 1.7.0):

Add the Rails Assets' source and Sprite-Up gem to your Gemfile, like this:

```ruby
source 'https://rails-assets.org' do
gem 'rails-assets-sprite-up'
end
```

And then run:

```bash
bundle install
```

2. Import Sprite-Up in your main scss/sass stylesheet:

```scss
@import "sprite-up/sprite-up";
```

## Build your sprites

1. Folder rganization is the key! Sprite-up creates the icon's CSS selector by looking for your images in different folders (retina and non-retina). It will create a CSS selector for each image found respectively, as long as you've added it into the right folder.

We suggest you name your folders like "non-retina" and "retina" under `app/assets/images/icons` and `app/assets/images/retina-icons` respectively.

Important: take in consideration to divide the measures of retina icons by two for the non-retina ones. That is,
if the retina icon is 32x32 then the non-retina icon must be 16x16. If you don't follow this instruction your icons won't look aligned.

2. Include the `sprite-up` mixin in your stylesheet (i.e _icons.sass partial or _images.sass partial)

```sass
+sprite-up("icons/*.png", "retina-icons/*.png")
```

We all know you’d probably need more than one sprite in your project. Worry not, you can generate as many sprites as you need as long as you have your images folders in separated directories.

```sass
+sprite-up("icons/*.png", "retina-icons/*.png")
+sprite-up("home-icons/*.png", "home-retina-icons/*.png", "home")
```

3. You are ready to go

Sprite files generated: `/images/icons-.png` and `/images/retina-icons-.png`

The css output will be something like:

```css
/* ... */

.icons-beautiful-icon {
background-image: url("/images/icons-s6702f5f04e.png");
/* ... */
}
@media /* big media query */ {
.icons-beautiful-icon {
background-image: url("/images/retina-icons-se1e882e708.png");
/* ... */
}
}

/* ... */

.home-pretty-icon {
background-image: url("/images/home-icons-scb1395e685.png");
/* ... */
}
@media /* big media query */ {
.home-pretty-icon {
background-image: url("/images/home-retina-icons-sc376afb714.png");
/* ... */
}
}

/* ... */
```

You don't need to create any class for any icon, they are autogenerated.

The only thing you'll need to maintain are your images. Remove them when they are not necesary, sprite-up will take care of the sprites and your css will remain untouched.

## Requirements

[compass](https://github.com/compass/compass) >= 0.12.2

## Testing

Tested against `compass-0.12.X` and `compass-1.0.1`

## Run middleman example

```bash
$ git clone [email protected]:restorando/sprite-up.git
$ cd examples/middleman
$ bundle install
# ...
$ bower install
# ...
$ middleman
# ...
```

Visit `http://localhost:4567`

## Version

0.1.1

## License

Copyright (c) 2013 Restorando

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.