compass-retinator 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/README.md +83 -0
- data/Rakefile +1 -0
- data/compass-retinator.gemspec +23 -0
- data/example/demo.sass +28 -0
- data/lib/compass-retinator.rb +7 -0
- data/lib/compass-retinator/version.rb +5 -0
- data/stylesheets/_compass_retinator.sass +5 -0
- data/stylesheets/partials/_retinator.sass +40 -0
- metadata +72 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
## Compass Retinator
|
2
|
+
|
3
|
+
This Compass extension will allow you to create retina ready sprites from scratch. Just drop your images on the right folders, type some Compass mumble jumble and you are ready to go!
|
4
|
+
|
5
|
+
##Installation
|
6
|
+
|
7
|
+
gem installl compass-retinator
|
8
|
+
|
9
|
+
Now do a require in your Compass <kbd>config.rb</kbd>
|
10
|
+
|
11
|
+
require 'compass-retinator'
|
12
|
+
|
13
|
+
## How to use it?
|
14
|
+
|
15
|
+
Fisrt thing to do is drop your images on the right folders. In this case I have set two folders <kbd>icons</kbd> and <kbd>icons-sprites</kbd> inside my image folder.
|
16
|
+
|
17
|
+
Next, we need to tell Compass where those image are. Add this line to <kbd>variables.saas</kbd> or somewhere else
|
18
|
+
|
19
|
+
$sprites: sprite-map("icons/*.png")
|
20
|
+
$sprites_retina: sprite-map("icons-sprites/*.png")
|
21
|
+
|
22
|
+
|
23
|
+
Now we need to init awesomeness, add this line to your project:
|
24
|
+
|
25
|
+
@import "compass-retinator"
|
26
|
+
|
27
|
+
## Using the extension
|
28
|
+
|
29
|
+
You can pass several parameters to obtain the right result, some valid options are:
|
30
|
+
|
31
|
+
// This will import plain.png
|
32
|
+
.plain
|
33
|
+
+sprite(plain)
|
34
|
+
|
35
|
+
// This will import boat.png, boat_hover.png and boat_active.png
|
36
|
+
.boat
|
37
|
+
+sprite(boat, $hover_state: true, $active_state: true)
|
38
|
+
|
39
|
+
// This will import console.png plus 40px of padding on the sides
|
40
|
+
.console
|
41
|
+
+sprite(console, $spacing: 40px)
|
42
|
+
|
43
|
+
// This will import people.png and it will not set any dimension on this elemments
|
44
|
+
.people
|
45
|
+
+sprite(people, $dimensions: False)
|
46
|
+
|
47
|
+
## Commmons Issues
|
48
|
+
|
49
|
+
### The sprite position is wrong
|
50
|
+
|
51
|
+
Please make you sure that your icons scale proportionally. If the non-retina icons are **16x16** your retina icons must be **32x32** and not **30x32** and definitely not **45x34**
|
52
|
+
|
53
|
+
### I'm getting a _compass can't convert nil into string_ error
|
54
|
+
|
55
|
+
You probably are running a rails app. This is a weird issue with compass-rails. For some reason compass-rails does not create the sprites on demand and do not understand the `sprite-map`.
|
56
|
+
|
57
|
+
One walkaround is to tell Compass to re-declare your sprites assets, so add this line at the top of your variables:
|
58
|
+
|
59
|
+
@import "icons/*.png"
|
60
|
+
@import "icons-sprites/*.png"
|
61
|
+
|
62
|
+
### The smart layout doesn't seems to work properly
|
63
|
+
|
64
|
+
Unfortunately Compass doesn't support extra options with this layout. Try to use the default layout or the horizontal layout.
|
65
|
+
|
66
|
+
### When I add some _spacing_ to my sprite the sprite position is not right
|
67
|
+
|
68
|
+
Please keept in mind that if you are adding extra padding around the sprite item you will also need to tell Compass to add some extra space on every sprite item. Just past the varible `$spacing: XXpx`
|
69
|
+
|
70
|
+
$sprites: sprite-map("icons/*.png", $spacing: 10px)
|
71
|
+
$sprites_retina: sprite-map("icons-sprites/*.png", $spacing: 20px)
|
72
|
+
|
73
|
+
## Licence
|
74
|
+
|
75
|
+
Copyright (c) 2013 Restorando
|
76
|
+
|
77
|
+
MIT License
|
78
|
+
|
79
|
+
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:
|
80
|
+
|
81
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
82
|
+
|
83
|
+
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.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
require 'compass-retinator/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "compass-retinator"
|
9
|
+
spec.version = CompassRetinator::VERSION
|
10
|
+
spec.authors = ["Restorando"]
|
11
|
+
spec.email = ["dev@restorando.com"]
|
12
|
+
spec.description = %q{Easily create sprites that support retina}
|
13
|
+
spec.summary = %q{Compass plugin to create sprite for retina devices}
|
14
|
+
spec.homepage = "https://github.com/restorando/compass-retinator"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "compass", "~> 0.12.0"
|
23
|
+
end
|
data/example/demo.sass
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
//Add compass
|
2
|
+
@import compass
|
3
|
+
|
4
|
+
// Compass-Rasils walkaround
|
5
|
+
@import "icons/*.png"
|
6
|
+
@import "icons-sprites/*.png"
|
7
|
+
|
8
|
+
// My sprites
|
9
|
+
$sprites: sprite-map("icons/*.png", $spacing: 10px)
|
10
|
+
$sprites_retina: sprite-map("icons-sprites/*.png", $spacing: 20px)
|
11
|
+
|
12
|
+
@import compass_retinator
|
13
|
+
|
14
|
+
//Create a single button
|
15
|
+
.my-button
|
16
|
+
+sprite(my-button)
|
17
|
+
|
18
|
+
//Create a single button withhover and active states
|
19
|
+
.my-button-2
|
20
|
+
+sprite(my-button-2, $hover_state: true, $active_state: true)
|
21
|
+
|
22
|
+
//Create a single button and add 40px of padding around
|
23
|
+
.my-button-3
|
24
|
+
+sprite(my-button-3, $spacing: 40px)
|
25
|
+
|
26
|
+
//Create a single button with no dimensions by default
|
27
|
+
.my-button-4
|
28
|
+
+sprite(my-button-3, $dimensions: false)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
=sprite($item_name, $hover_state: false, $active_state: false, $dimensions: true, $spacing: 0)
|
2
|
+
+retina-sprite($item_name, $sprites, $sprites_retina, $hover_state, $active_state, $dimensions, $spacing)
|
3
|
+
|
4
|
+
=retina-sprite($item_name, $sprites, $sprites_retina, $hover_state, $active_state, $dimensions, $spacing)
|
5
|
+
$hover_state: false !default
|
6
|
+
$active_state: false !default
|
7
|
+
$dimensions: true !default
|
8
|
+
$media-queries: "(-webkit-min-device-pixel-ratio: 1.25), (min-resolution: 120dpi), (-webkit-min-device-pixel-ratio: 1.3), (min-resolution: 124.8dpi), (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi), (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)"
|
9
|
+
|
10
|
+
background: sprite-url($sprites) sprite-position($sprites, $item_name, $spacing, $spacing) no-repeat
|
11
|
+
|
12
|
+
@if $hover_state
|
13
|
+
$item_name_hover: $item_name + _hover
|
14
|
+
&:hover
|
15
|
+
background-position: sprite-position($sprites, $item_name_hover, $spacing, $spacing)
|
16
|
+
@media #{$media-queries}
|
17
|
+
$item_name_hover: $item_name + _hover
|
18
|
+
$sprite_position: sprite-position($sprites_retina, $item_name_hover, $spacing * 2, $spacing * 2)
|
19
|
+
background-position: nth($sprite_position, 1) /2 nth($sprite_position, 2) / 2
|
20
|
+
|
21
|
+
@if $active_state
|
22
|
+
$item_name_active: $item_name + _active
|
23
|
+
&:active
|
24
|
+
background-position: sprite-position($sprites, $item_name_active, $spacing, $spacing)
|
25
|
+
@media #{$media-queries}
|
26
|
+
$item_name_active: $item_name + _active
|
27
|
+
$sprite_position: sprite-position($sprites_retina, $item_name_active, $spacing * 2, $spacing * 2)
|
28
|
+
background-position: nth($sprite_position, 1) /2 nth($sprite_position, 2) / 2
|
29
|
+
|
30
|
+
@if $spacing > 0
|
31
|
+
padding: $spacing
|
32
|
+
|
33
|
+
@if $dimensions
|
34
|
+
+sprite-dimensions($sprites, $item_name)
|
35
|
+
|
36
|
+
@media #{$media-queries}
|
37
|
+
&
|
38
|
+
$sprite_position: sprite-position($sprites_retina, $item_name, $spacing * 2, $spacing * 2)
|
39
|
+
background: sprite-url($sprites_retina) nth($sprite_position, 1) /2 nth($sprite_position, 2) / 2 no-repeat
|
40
|
+
+background-size(ceil(image-width(sprite-path($sprites_retina)) / 2) auto)
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: compass-retinator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Restorando
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-07-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: compass
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.12.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.12.0
|
30
|
+
description: Easily create sprites that support retina
|
31
|
+
email:
|
32
|
+
- dev@restorando.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- README.md
|
40
|
+
- Rakefile
|
41
|
+
- compass-retinator.gemspec
|
42
|
+
- example/demo.sass
|
43
|
+
- lib/compass-retinator.rb
|
44
|
+
- lib/compass-retinator/version.rb
|
45
|
+
- stylesheets/_compass_retinator.sass
|
46
|
+
- stylesheets/partials/_retinator.sass
|
47
|
+
homepage: https://github.com/restorando/compass-retinator
|
48
|
+
licenses:
|
49
|
+
- MIT
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.8.25
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Compass plugin to create sprite for retina devices
|
72
|
+
test_files: []
|