Sprites
Sprites is a library that let's you define the sprites for your application with configuration or convention. Sprites will generate your sprites, and a corresponding stylesheet for each using either the cli or from within a Rails application.
The DSL for sprites.rb
sprite :bas
sprite :buttons, :path => "buttons.png", :stylesheet_path => "buttons.css", :autoload => false do
sprite_piece 'buttons/btn-black-default-28.png', 'a.black.button > span, button.black.submit span'
sprite_piece 'buttons/btn-black-default-cap-28.png', 'a.black.button, button.black.submit', :x => 'right'
...
endFor the cli
Project Structure
|
|\_config
| \_sprites.rb
\_public
\_images
\_sprite_images
|\_sprite_name1
| |\_blue_icon.png
| \_green_icon.png
\_sprite_name2
|\_blue_icon.png
\_green_icon.png
gem install sprites
execute:
cd PROJECT_ROOT
sprites
For usage
sprites --help
In your Rails app
Gemfile
gem 'sprites'application.rb
config.uses_sprites = trueOptionally include a config/sprites.rb (see above). Otherwise Sprites will use it's auto-load feature. Example, if you have app/assets/images/sprite_images/foo/bar.png and app/assets/images/sprite_images/foo/bas.png, Sprites will create app/assets/stylesheets/sprites/foo.css and app/assets/images/sprites/foo.png. The class for bar.png will be .bar and for bas.png, .bas, etc.
rake sprites
to generate.
In your Rails Engine
engine.rb
module MyGem
class Engine < Rails::Engine
config.uses_sprites = true
end
endUse app/assets in your gem like you would your rails app and use the asset pipeline.
From your rails root
ENGINES=true rake sprites
Note: this will generate your sprites for your Sprites enabled Engines and your Sprites enabled Rails app.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request