compass-spriter 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +59 -0
- data/lib/compass-spriter.rb +3 -0
- data/stylesheets/_spriter.scss +32 -0
- metadata +62 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2d4829a20248267871b5d6173503fff65648c074
|
4
|
+
data.tar.gz: 281af62e6abba37e3e2fe5e0ee80fcc8d86ef76f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 18b4345ed87fd052d989045965c7850fe41a347ccc2f68b6508b3f99a951752b387fdabf52620257d75162003ead40ccfb0fb2f5b327eceb316360aa5cd62e2f
|
7
|
+
data.tar.gz: 21ad8c16f6389bba9bffae19d1b680fbfb559628aa5856e48b7d069bcc9fe089dc726aeb9f5e0bed1204045b06e81c57382ec8900de1f5415c8968404fd6ce2f
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Compass Spriter
|
2
|
+
|
3
|
+
A *responsive* [sprite sheet](http://css-tricks.com/css-sprites/) generator plugin for [Compass](http://compass-style.org/).
|
4
|
+
|
5
|
+
There are many sprite generators out there, and even one [built in to compass](http://compass-style.org/reference/compass/helpers/sprites/#sprite-map). However, none of these sprite sheet generators can be applied to responsively sized elements.
|
6
|
+
If you have an element with a percentage width or height, you will need a percentage background-position, which this plugin provides.
|
7
|
+
|
8
|
+
##Installation
|
9
|
+
|
10
|
+
```
|
11
|
+
$ gem install compass-spriter
|
12
|
+
```
|
13
|
+
|
14
|
+
##Usage
|
15
|
+
|
16
|
+
When creating a new project for Compass
|
17
|
+
|
18
|
+
```
|
19
|
+
$ compass create <my_project> -r compass-spriter --using compass-spriter
|
20
|
+
```
|
21
|
+
|
22
|
+
If using an existing project, edit your config.rb and add this line:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
require 'compass-spriter'
|
26
|
+
```
|
27
|
+
|
28
|
+
To use the responsive sprite mixin
|
29
|
+
|
30
|
+
```scss
|
31
|
+
@import "spriter";
|
32
|
+
|
33
|
+
div#menu-icon{
|
34
|
+
@include spriter(menu-icon);
|
35
|
+
}
|
36
|
+
|
37
|
+
```
|
38
|
+
|
39
|
+
##Options
|
40
|
+
|
41
|
+
You can configure Spriter's settings (defaults shown below).
|
42
|
+
|
43
|
+
If you want to override these settings, you _must_ set the variables before the first use of `@include spriter();`
|
44
|
+
|
45
|
+
```scss
|
46
|
+
//glob of images to use in the sprite sheet
|
47
|
+
$spriter-images: "sprites/*.png";
|
48
|
+
|
49
|
+
//number of pixels of space between sprites
|
50
|
+
$spriter-spacing: 2px;
|
51
|
+
```
|
52
|
+
|
53
|
+
##Browser support
|
54
|
+
|
55
|
+
Browser support very generally good. Any browser that supports percentage-positioned background images should be fine.
|
56
|
+
|
57
|
+
##Contributions
|
58
|
+
|
59
|
+
Pull requests or the opening of issues are always welcome
|
@@ -0,0 +1,32 @@
|
|
1
|
+
$spriter-images: "sprites/*.png" !default;
|
2
|
+
$spriter-spacing: 2px !default;
|
3
|
+
|
4
|
+
$_spriter-icons: false;
|
5
|
+
|
6
|
+
@mixin responsive-sprite($name){
|
7
|
+
@if $_spriter-icons{
|
8
|
+
//$_spriter-icons is already set
|
9
|
+
}@else{
|
10
|
+
$_spriter-icons : sprite-map($spriter-images, $spacing:$spriter-spacing) !global;
|
11
|
+
}
|
12
|
+
background-image:$_spriter-icons;
|
13
|
+
$totalHeight : image-height(sprite-path($_spriter-icons));
|
14
|
+
$totalWidth : image-width(sprite-path($_spriter-icons));
|
15
|
+
$spriteHeight : image-height(sprite-file($_spriter-icons, $name));
|
16
|
+
$spriteWidth : image-width(sprite-file($_spriter-icons, $name));
|
17
|
+
$spritePosX : nth(sprite-position($_spriter-icons, $name), 1) + 0px;
|
18
|
+
$spritePosY : nth(sprite-position($_spriter-icons, $name), 2) + 0px;
|
19
|
+
|
20
|
+
$background-position-x:0;
|
21
|
+
$background-position-y:0;
|
22
|
+
|
23
|
+
background-size:100% * ($totalWidth / $spriteWidth) 100% * ($totalHeight / $spriteHeight);
|
24
|
+
@if ($totalHeight - $spriteHeight > 0){
|
25
|
+
$background-position-y:100% * ((-$spritePosY / ($totalHeight - $spriteHeight)));
|
26
|
+
}
|
27
|
+
@if ($totalWidth - $spriteWidth > 0){
|
28
|
+
$background-position-x:100% * ((-$spritePosX / ($totalWidth - $spriteWidth)));
|
29
|
+
}
|
30
|
+
background-position:$background-position-x $background-position-y;
|
31
|
+
background-repeat:no-repeat;
|
32
|
+
}
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: compass-spriter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Monteith
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2011-12-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: compass
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.1
|
27
|
+
description: Sprite generator for compass, using percentages for responsively sized
|
28
|
+
sprites
|
29
|
+
email: mike@mikemonteith.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- README.md
|
35
|
+
- lib/compass-spriter.rb
|
36
|
+
- stylesheets/_spriter.scss
|
37
|
+
homepage: http://mikemonteith.com
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 2.0.14
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: Responsive sprite generator for compass
|
61
|
+
test_files: []
|
62
|
+
has_rdoc:
|