SassyIcons 0.0.10 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +19 -45
- data/lib/SassyIcons.rb +0 -11
- data/stylesheets/_SassyIcons.scss +4 -5
- data/stylesheets/config/_config.scss +29 -12
- data/stylesheets/helpers/_helpers.scss +65 -55
- data/stylesheets/icons/_generated.scss +30 -13
- data/stylesheets/icons/_icon-generated.scss +26 -14
- data/stylesheets/icons/_icon-single.scss +22 -13
- data/stylesheets/icons/_icon.scss +28 -15
- data/stylesheets/icons/_sprite-map-create.scss +24 -10
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f03ecf0b13d130ed13c61cf91889548e9b1314ff
|
4
|
+
data.tar.gz: 215f06661d40027eded677a032749ca0d7f94722
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cfbc5a56375f46a6bfadc086977cebd2b25f52163ed3c4404388e18d1f5cf8b28d337ca6d8cfd619541751b13cea9a4f268f0e62820afe9158d8d36951c832d
|
7
|
+
data.tar.gz: 19f972b41e25e952d1a721274e7a9102e9fc7a0dfbfe2521dc684e5ae50f83d3397dcc8cb1e931ccfc27f8669755e4e6d880e70ed0a1c0a57f99e8de8cd4369f
|
data/README.md
CHANGED
@@ -10,32 +10,17 @@ SVG first with PNG sprite fallback, or PNG first with hidpi sprite support.
|
|
10
10
|
Also managing several "thematic" sprites a breeze.
|
11
11
|
|
12
12
|
|
13
|
-
*Best workflow used in conjunction with [grunt-svg2png](https://github.com/pascalduez/grunt-svg2png)
|
13
|
+
*Best workflow used in conjunction with [grunt-svg2png](https://github.com/pascalduez/grunt-svg2png).*
|
14
14
|
|
15
|
+
*Online [preview](http://pascalduez.github.io/SassyIcons/test) (test folder).*
|
16
|
+
*Online [Documentation](http://pascalduez.github.io/SassyIcons/docs) (generated with SassDoc).*
|
15
17
|
|
16
18
|
## Mixins
|
17
19
|
|
18
20
|
`sprite-map-create($name [, $spacing])`
|
19
|
-
`icon($
|
20
|
-
`icon-single($
|
21
|
-
`icon-generated($
|
22
|
-
|
23
|
-
|
24
|
-
## Documentation
|
25
|
-
|
26
|
-
**sprite-map-create($name)**
|
27
|
-
Create a new sprite map from folder.
|
28
|
-
|
29
|
-
**icon($name, $sprite [, $offset, $format])**
|
30
|
-
Main icon mixin.
|
31
|
-
|
32
|
-
**icon-single($name, $sprite [, $format])**
|
33
|
-
Embed a single icon as inline-image (no sprite).
|
34
|
-
Should be used sporadically.
|
35
|
-
|
36
|
-
**icon-generated($name, $sprite [, $pos, $centered, $format])**
|
37
|
-
Include the icon in a generated "pseudo-element". Default to :before.
|
38
|
-
Allows for easier positioning or centering.
|
21
|
+
`icon($map, $sprite [, $offset, $format])`
|
22
|
+
`icon-single($map, $sprite [, $format])`
|
23
|
+
`icon-generated($map, $sprite [, $pos, $centered, $format])`
|
39
24
|
|
40
25
|
|
41
26
|
## Configuration
|
@@ -44,13 +29,13 @@ Allows for easier positioning or centering.
|
|
44
29
|
// Default settings.
|
45
30
|
$icons-defaults: (
|
46
31
|
|
47
|
-
// Space around sprites in generated
|
32
|
+
// Space around sprites in generated spritemap.
|
48
33
|
// Useful with `$offset` parameter.
|
49
|
-
// This setting is global for all
|
50
|
-
// Can be set per
|
34
|
+
// This setting is global for all spritemaps.
|
35
|
+
// Can be set per spritemap with the `$spacing` parameter.
|
51
36
|
spacing: 0,
|
52
37
|
|
53
|
-
// Main icons directory. sprite-map-create()
|
38
|
+
// Main icons directory. `sprite-map-create()`, base for sub dirs.
|
54
39
|
dir: "icons",
|
55
40
|
|
56
41
|
// Name of the png sub-folders.
|
@@ -65,7 +50,7 @@ $icons-defaults: (
|
|
65
50
|
// Minimum resolution ratio used in the hidpi media query.
|
66
51
|
hidpi-ratio: 1.3,
|
67
52
|
|
68
|
-
// Whether to embed icons as data URI in the icon-single() mixin.
|
53
|
+
// Whether to embed icons as data URI in the `icon-single()` mixin.
|
69
54
|
single-embed: true,
|
70
55
|
|
71
56
|
// Default file format unless overridden by parameter, svg | png.
|
@@ -82,7 +67,7 @@ Override default values in a new `$icons-settings` map.
|
|
82
67
|
## Requirements
|
83
68
|
|
84
69
|
* Sass ~> 3.3.0
|
85
|
-
* Compass ~> 1.0.0.
|
70
|
+
* Compass ~> 1.0.0.rc.1
|
86
71
|
|
87
72
|
|
88
73
|
## Install
|
@@ -107,33 +92,22 @@ bower install SassyIcons --save
|
|
107
92
|
|
108
93
|
#### Compass extension
|
109
94
|
|
110
|
-
|
111
|
-
2. Add `require 'SassyIcons'` to your `config.rb`
|
112
|
-
3. Import it in your stylesheets with `@import 'SassyIcons'`
|
95
|
+
Since SassyIcons is dependant on Compass, this is the recommended installation and usage.
|
113
96
|
|
97
|
+
1. Add `gem 'SassyIcons', '~>0.1.0'` to your `Gemfile`
|
98
|
+
2. `bundle install --path .` (manage your gems in project dir, not globally)
|
99
|
+
3. Add `require 'SassyIcons'` to your `config.rb`
|
100
|
+
4. Import it in your stylesheets with `@import 'SassyIcons'`
|
114
101
|
|
115
|
-
## Usage
|
116
102
|
|
117
|
-
|
103
|
+
## Usage
|
118
104
|
|
119
105
|
#### Example usage with [Compass](http://compass-style.org/help/tutorials/command-line)
|
120
106
|
```css
|
121
107
|
@import 'SassyIcons';
|
122
108
|
```
|
123
109
|
```
|
124
|
-
bundle exec compass watch
|
125
|
-
```
|
126
|
-
|
127
|
-
#### Example config with [grunt-contrib-sass](https://github.com/gruntjs/grunt-contrib-sass)
|
128
|
-
|
129
|
-
```js
|
130
|
-
sass: {
|
131
|
-
options: {
|
132
|
-
bundleExec: true, // Optional usage of Bundler, but recommended.
|
133
|
-
compass: true,
|
134
|
-
loadPath: ['[path]/dist/_SassyIcons.scss']
|
135
|
-
}
|
136
|
-
}
|
110
|
+
bundle exec compass watch
|
137
111
|
```
|
138
112
|
|
139
113
|
|
data/lib/SassyIcons.rb
CHANGED
@@ -2,14 +2,3 @@ require 'compass'
|
|
2
2
|
|
3
3
|
extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
4
4
|
Compass::Frameworks.register('SassyIcons', :path => extension_path)
|
5
|
-
|
6
|
-
# Version is a number. If a version contains alphas, it will be created as a prerelease version
|
7
|
-
# Date is in the form of YYYY-MM-DD
|
8
|
-
module SassyIcons
|
9
|
-
VERSION = "0.0.10"
|
10
|
-
DATE = "2014-06-09"
|
11
|
-
end
|
12
|
-
|
13
|
-
module Sass::Script::Functions
|
14
|
-
|
15
|
-
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
//
|
1
|
+
// -----------------------------------------------------------------------------
|
2
2
|
// SassyIcons - Flexible icons system.
|
3
|
-
//
|
3
|
+
// -----------------------------------------------------------------------------
|
4
4
|
// Repository: https://github.com/pascalduez/SassyIcons
|
5
|
-
//
|
5
|
+
// -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
// A bit of terminology:
|
8
8
|
// sprite = a single image/icon
|
9
|
-
//
|
9
|
+
// 'sprite-sheet' or 'sprite-map' == all sprites combined together
|
10
10
|
|
11
11
|
//
|
12
12
|
// Import configuration
|
@@ -18,7 +18,6 @@
|
|
18
18
|
//
|
19
19
|
@import "helpers/helpers";
|
20
20
|
|
21
|
-
|
22
21
|
//
|
23
22
|
// Import icons
|
24
23
|
//
|
@@ -1,19 +1,22 @@
|
|
1
|
-
//
|
2
|
-
// SassyIcons
|
3
|
-
//
|
4
1
|
|
5
|
-
//
|
2
|
+
// SassyIcons: configuration
|
3
|
+
// -------------------------
|
6
4
|
|
7
|
-
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Default settings.
|
8
|
+
* ---
|
9
|
+
* @type Map
|
10
|
+
*/
|
8
11
|
$icons-defaults: (
|
9
12
|
|
10
|
-
// Space around sprites in generated
|
13
|
+
// Space around sprites in generated spritemap.
|
11
14
|
// Useful with `$offset` parameter.
|
12
|
-
// This setting is global for all
|
13
|
-
// Can be set per
|
15
|
+
// This setting is global for all spritemaps.
|
16
|
+
// Can be set per spritemap with the `$spacing` parameter.
|
14
17
|
spacing: 0,
|
15
18
|
|
16
|
-
// Main icons directory. sprite-map-create()
|
19
|
+
// Main icons directory. `sprite-map-create()`, base for sub dirs.
|
17
20
|
dir: "icons",
|
18
21
|
|
19
22
|
// Name of the png sub-folders.
|
@@ -28,7 +31,7 @@ $icons-defaults: (
|
|
28
31
|
// Minimum resolution ratio used in the hidpi media query.
|
29
32
|
hidpi-ratio: 1.3,
|
30
33
|
|
31
|
-
// Whether to embed icons as data URI in the icon-single() mixin.
|
34
|
+
// Whether to embed icons as data URI in the `icon-single()` mixin.
|
32
35
|
single-embed: true,
|
33
36
|
|
34
37
|
// Default file format unless overridden by parameter, svg | png.
|
@@ -39,10 +42,24 @@ $icons-defaults: (
|
|
39
42
|
|
40
43
|
);
|
41
44
|
|
42
|
-
|
45
|
+
|
46
|
+
/**
|
47
|
+
* User settings.
|
48
|
+
* ---
|
49
|
+
* @type Map
|
50
|
+
*/
|
43
51
|
$icons-settings: () !default;
|
44
52
|
|
45
|
-
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Retrieve a configuration item.
|
56
|
+
* ---
|
57
|
+
* @access private
|
58
|
+
* ---
|
59
|
+
* @param {String} $key - configuration item key
|
60
|
+
* ---
|
61
|
+
* @return {*}
|
62
|
+
*/
|
46
63
|
@function conf($key) {
|
47
64
|
@if not map-has-key($icons-defaults, $key) {
|
48
65
|
@warn "No item `#{$key}` found in configuration.";
|
@@ -1,28 +1,24 @@
|
|
1
1
|
|
2
|
-
//
|
3
|
-
//
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
}
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
// -----------------------------------------------------------------------------
|
21
|
-
// @return [string]
|
22
|
-
|
23
|
-
@function _join($list, $glue: "") {
|
24
|
-
$result: "";
|
2
|
+
// SassyIcons: helpers
|
3
|
+
// -------------------
|
4
|
+
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Helper: join `$list` into a string.
|
8
|
+
* ---
|
9
|
+
* @access private
|
10
|
+
* ---
|
11
|
+
* @param {List} $list - the list to convert
|
12
|
+
* @param {String} $glue ('') - a string to separate each element of the list
|
13
|
+
* ---
|
14
|
+
* @return {String}
|
15
|
+
*/
|
16
|
+
@function _join(
|
17
|
+
$list,
|
18
|
+
$glue: ''
|
19
|
+
) {
|
25
20
|
$length: length($list);
|
21
|
+
$result: '';
|
26
22
|
|
27
23
|
@if $length < 1 {
|
28
24
|
@return $result;
|
@@ -31,52 +27,66 @@
|
|
31
27
|
@for $i from 1 through $length {
|
32
28
|
$result: $result
|
33
29
|
+ nth($list, $i)
|
34
|
-
+ if($i != $length, $glue,
|
30
|
+
+ if($i != $length, $glue, '');
|
35
31
|
}
|
36
32
|
|
37
33
|
@return $result;
|
38
34
|
}
|
39
35
|
|
40
36
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
37
|
+
/**
|
38
|
+
* Helper: retrieve a spritemap.
|
39
|
+
* ---
|
40
|
+
* @access private
|
41
|
+
* ---
|
42
|
+
* @param {String} $name - spritemap name
|
43
|
+
* @param {String} $factor (1x) - dpi factor
|
44
|
+
* ---
|
45
|
+
* @return {Spritemap}
|
46
|
+
*/
|
47
|
+
@function _sprite-map-get(
|
48
|
+
$name,
|
49
|
+
$factor: 1x
|
50
|
+
) {
|
51
|
+
@return map-get(map-get($icons-spritemaps, $name), $factor);
|
51
52
|
}
|
52
53
|
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
@
|
55
|
+
/**
|
56
|
+
* Helper: return correct spritemap `background-position`.
|
57
|
+
* ---
|
58
|
+
* @access private
|
59
|
+
* ---
|
60
|
+
* @param {Spritemap} $map - spritemap name
|
61
|
+
* @param {String} $sprite - sprite name
|
62
|
+
* @param {Number} $offset-x (0) - adjustment along the x axis
|
63
|
+
* @param {Number} $offset-y (0) - adjustment along the y axis
|
64
|
+
* @param {Number} $scale (1) - spritemap scale
|
65
|
+
* ---
|
66
|
+
* @return {List} (x-pos y-pos)
|
67
|
+
*/
|
68
|
+
@function _sprite-position(
|
69
|
+
$map,
|
70
|
+
$sprite,
|
71
|
+
$offset-x: 0,
|
72
|
+
$offset-y: 0,
|
73
|
+
$scale: 1
|
74
|
+
) {
|
66
75
|
$pos: sprite-position($map, $sprite, $offset-x, $offset-y * $scale);
|
67
76
|
@return (nth($pos, 1) nth($pos, 2) / $scale);
|
68
77
|
}
|
69
78
|
|
70
79
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
+
/**
|
81
|
+
* Hidpi media query builder.
|
82
|
+
* ---
|
83
|
+
* @access private
|
84
|
+
* ---
|
85
|
+
* @link http://bjango.com/articles/min-device-pixel-ratio/
|
86
|
+
* @link http://brettjankord.com/2012/11/28/cross-browser-retinahigh-resolution-media-queries
|
87
|
+
* @link http://w3.org/blog/CSS/2012/06/14/unprefix-webkit-device-pixel-ratio
|
88
|
+
*/
|
89
|
+
@mixin hidpi-mq {
|
80
90
|
$hidpi-ratio: conf(hidpi-ratio);
|
81
91
|
|
82
92
|
@media (-webkit-min-device-pixel-ratio: $hidpi-ratio),
|
@@ -1,20 +1,37 @@
|
|
1
1
|
|
2
|
-
//
|
3
|
-
//
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
// SassyIcons: generated
|
3
|
+
// ---------------------
|
4
|
+
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Boilerplate styles for generated content `:before` or `:after`.
|
8
|
+
* ---
|
9
|
+
* @access private
|
10
|
+
* ---
|
11
|
+
* @param {Number} $width
|
12
|
+
* @param {Number} $height
|
13
|
+
* @param {Number} $top
|
14
|
+
* @param {Number} $right
|
15
|
+
* @param {Number} $bottom
|
16
|
+
* @param {Number} $left
|
17
|
+
*/
|
18
|
+
@mixin generated(
|
19
|
+
$width: false,
|
20
|
+
$height: false,
|
21
|
+
$top: false,
|
22
|
+
$right: false,
|
23
|
+
$bottom: false,
|
24
|
+
$left: false
|
25
|
+
) {
|
26
|
+
@if $width { width: $width };
|
27
|
+
@if $height { height: $height };
|
11
28
|
content: "";
|
12
29
|
display: block;
|
13
30
|
position: absolute;
|
14
|
-
@if
|
15
|
-
@if
|
16
|
-
@if
|
17
|
-
@if
|
31
|
+
@if $top { top: $top; }
|
32
|
+
@if $right { right: $right; }
|
33
|
+
@if $bottom { bottom: $bottom; }
|
34
|
+
@if $left { left: $left; }
|
18
35
|
z-index: 1;
|
19
36
|
|
20
37
|
@content;
|
@@ -1,37 +1,49 @@
|
|
1
|
-
|
2
|
-
// SassyIcons
|
3
|
-
//
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
|
2
|
+
// SassyIcons: icon-generated
|
3
|
+
// --------------------------
|
4
|
+
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Include the icon in a generated pseudo-element.
|
8
|
+
* Default to `:before`.
|
9
|
+
* Allows for easier positioning or centering.
|
10
|
+
* ---
|
11
|
+
* @requires conf
|
12
|
+
* @requires _sprite-map-get
|
13
|
+
* @requires {mixin} generated
|
14
|
+
* @requires {mixin} icon
|
15
|
+
* ---
|
16
|
+
* @param {String} $map - spritemap name
|
17
|
+
* @param {String} $sprite - sprite name
|
18
|
+
* @param {String} $pos ('before') - pseudo-element position
|
19
|
+
* @param {Bool} $centered (false) - whether to center the icon, relative to its parent
|
20
|
+
* @param {String} $format (conf(format)) - file format 'svg' | 'png'
|
21
|
+
*/
|
10
22
|
@mixin icon-generated(
|
11
|
-
$
|
23
|
+
$map,
|
12
24
|
$sprite,
|
13
|
-
$pos:
|
25
|
+
$pos: 'before',
|
14
26
|
$centered: false,
|
15
27
|
$format: conf(format)
|
16
28
|
) {
|
17
29
|
position: relative;
|
18
30
|
|
19
31
|
&:#{$pos} {
|
20
|
-
$sprite-file: sprite-file(_sprite-map-get($
|
32
|
+
$sprite-file: sprite-file(_sprite-map-get($map), $sprite);
|
21
33
|
|
22
34
|
$width: image-width($sprite-file);
|
23
35
|
$height: image-height($sprite-file);
|
24
36
|
|
25
37
|
@include generated($width, $height);
|
26
38
|
|
27
|
-
@if
|
39
|
+
@if $centered {
|
28
40
|
top: 35%;
|
29
41
|
top: calc(50% - #{$height} / 2);
|
30
42
|
left: 35%;
|
31
43
|
left: calc(50% - #{$width} / 2);
|
32
44
|
}
|
33
45
|
|
34
|
-
@include icon($
|
46
|
+
@include icon($map: $map, $sprite: $sprite, $format: $format);
|
35
47
|
|
36
48
|
@content;
|
37
49
|
}
|
@@ -1,13 +1,21 @@
|
|
1
|
-
//
|
2
|
-
// SassyIcons
|
3
|
-
//
|
4
1
|
|
5
|
-
//
|
6
|
-
//
|
7
|
-
|
8
|
-
|
2
|
+
// SassyIcons: icon-single
|
3
|
+
// -----------------------
|
4
|
+
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Embed a single icon as inline-image (no spritemap).
|
8
|
+
* Should be used sporadically.
|
9
|
+
* ---
|
10
|
+
* @requires conf
|
11
|
+
* @requires _join
|
12
|
+
* ---
|
13
|
+
* @param {String} $map - spritemap name
|
14
|
+
* @param {String} $sprite - sprite name
|
15
|
+
* @param {String} $format (conf(format)) - file format 'svg' | 'png'
|
16
|
+
*/
|
9
17
|
@mixin icon-single(
|
10
|
-
$
|
18
|
+
$map,
|
11
19
|
$sprite,
|
12
20
|
$format: conf(format)
|
13
21
|
) {
|
@@ -16,9 +24,9 @@
|
|
16
24
|
// @see https://github.com/chriseppstein/compass/issues/951
|
17
25
|
|
18
26
|
$dir: conf(dir);
|
19
|
-
$svg-file: _join(($dir, $
|
20
|
-
$png-file-1x: _join(($dir, $
|
21
|
-
$png-file-2x: _join(($dir, $
|
27
|
+
$svg-file: _join(($dir, $map, '#{$sprite}.svg'), '/');
|
28
|
+
$png-file-1x: _join(($dir, $map, conf(dir-png), '#{$sprite}.png'), '/');
|
29
|
+
$png-file-2x: _join(($dir, $map, conf(dir-hidpi), '#{$sprite}.png'), '/');
|
22
30
|
|
23
31
|
$function: if(conf(single-embed), inline-image, image-url);
|
24
32
|
$svg-url: call($function, $svg-file);
|
@@ -27,9 +35,10 @@
|
|
27
35
|
|
28
36
|
$legacy-support: conf(legacy);
|
29
37
|
|
38
|
+
// Allow to pass format as uppercase.
|
30
39
|
$format: to-lower-case($format);
|
31
40
|
|
32
|
-
@if $format ==
|
41
|
+
@if $format == 'svg' {
|
33
42
|
|
34
43
|
background: {
|
35
44
|
image: $svg-url;
|
@@ -48,7 +57,7 @@
|
|
48
57
|
}
|
49
58
|
|
50
59
|
}
|
51
|
-
@else if $format ==
|
60
|
+
@else if $format == 'png' {
|
52
61
|
|
53
62
|
background: {
|
54
63
|
image: $png-url-1x;
|
@@ -1,18 +1,30 @@
|
|
1
|
-
//
|
2
|
-
// SassyIcons
|
3
|
-
//
|
4
1
|
|
5
|
-
//
|
6
|
-
//
|
7
|
-
|
2
|
+
// SassyIcons: icon
|
3
|
+
// ----------------
|
4
|
+
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Main icon mixin,
|
8
|
+
* default choice unless there are specific needs.
|
9
|
+
* ---
|
10
|
+
* @requires conf
|
11
|
+
* @requires _sprite-map-get
|
12
|
+
* @requires _join
|
13
|
+
* @requires _sprite-position
|
14
|
+
* ---
|
15
|
+
* @param {String} $map - spritemap name
|
16
|
+
* @param {String} $sprite - sprite name
|
17
|
+
* @param {List} $offset (0 0) - adjustment along the x y axis
|
18
|
+
* @param {String} $format (conf(format)) - file format 'svg' | 'png'
|
19
|
+
*/
|
8
20
|
@mixin icon(
|
9
|
-
$
|
21
|
+
$map,
|
10
22
|
$sprite,
|
11
23
|
$offset: 0 0,
|
12
24
|
$format: conf(format)
|
13
25
|
) {
|
14
|
-
$map-1x: _sprite-map-get($
|
15
|
-
$map-2x: _sprite-map-get($
|
26
|
+
$map-1x: _sprite-map-get($map);
|
27
|
+
$map-2x: _sprite-map-get($map, 2x);
|
16
28
|
|
17
29
|
// Shorter mixin calls.
|
18
30
|
$offset-x: nth($offset, 1);
|
@@ -20,11 +32,12 @@
|
|
20
32
|
|
21
33
|
$legacy-support: conf(legacy);
|
22
34
|
|
35
|
+
// Allow to pass format as uppercase.
|
23
36
|
$format: to-lower-case($format);
|
24
37
|
|
25
|
-
@if $format ==
|
38
|
+
@if $format == 'svg' {
|
26
39
|
|
27
|
-
$svg-file: _join((conf(dir), $
|
40
|
+
$svg-file: _join((conf(dir), $map, '#{$sprite}.svg'), '/');
|
28
41
|
|
29
42
|
background: {
|
30
43
|
image: inline-image($svg-file);
|
@@ -39,20 +52,20 @@
|
|
39
52
|
.no-svg &,
|
40
53
|
.no-js & {
|
41
54
|
|
42
|
-
@extend %sprite-map-#{$
|
55
|
+
@extend %sprite-map-#{$map}-image-map;
|
43
56
|
|
44
57
|
background-position: _sprite-position($map-1x, $sprite, $offset-x, $offset-y);
|
45
58
|
}
|
46
59
|
}
|
47
60
|
|
48
61
|
}
|
49
|
-
@else if $format ==
|
62
|
+
@else if $format == 'png' {
|
50
63
|
|
51
|
-
@extend %sprite-map-#{$
|
64
|
+
@extend %sprite-map-#{$map}-image-map;
|
52
65
|
|
53
66
|
background-position: _sprite-position($map-1x, $sprite, $offset-x, $offset-y);
|
54
67
|
|
55
|
-
@extend %sprite-map-#{$
|
68
|
+
@extend %sprite-map-#{$map}-2x-image-map;
|
56
69
|
|
57
70
|
@include hidpi-mq {
|
58
71
|
background-position: _sprite-position($map-2x, $sprite, $offset-x, $offset-y, conf(hidpi-scale));
|
@@ -1,25 +1,39 @@
|
|
1
|
-
//
|
2
|
-
// SassyIcons
|
3
|
-
//
|
4
1
|
|
5
|
-
//
|
6
|
-
|
2
|
+
// SassyIcons: sprite-map-create
|
3
|
+
// -----------------------------
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Spritemaps storage.
|
8
|
+
* ---
|
9
|
+
* @access private
|
10
|
+
* ---
|
11
|
+
* @type Map
|
12
|
+
*/
|
13
|
+
$icons-spritemaps: ();
|
14
|
+
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Create a new spritemap from folder.
|
18
|
+
* ---
|
19
|
+
* @requires conf
|
20
|
+
* @requires _join
|
21
|
+
* ---
|
22
|
+
* @param {String} $name - spritemap name, which is also the folder name
|
23
|
+
* @param {Number} $spacing (conf(spacing)) - Whether to add space around sprites in generated spritemap
|
24
|
+
*/
|
11
25
|
@mixin sprite-map-create(
|
12
26
|
$name,
|
13
27
|
$spacing: conf(spacing)
|
14
28
|
) {
|
15
|
-
|
16
29
|
$sprites-1x: _join((conf(dir), $name, conf(dir-png), "*.png"), "/");
|
17
30
|
$sprites-2x: _join((conf(dir), $name, conf(dir-hidpi), "*.png"), "/");
|
18
31
|
|
19
32
|
$map-1x: sprite-map($sprites-1x, $spacing: $spacing);
|
20
33
|
$map-2x: sprite-map($sprites-2x, $spacing: $spacing);
|
21
34
|
|
22
|
-
$
|
35
|
+
$new: ($name: (1x: $map-1x, 2x: $map-2x));
|
36
|
+
$icons-spritemaps: map-merge($icons-spritemaps, $new) !global;
|
23
37
|
|
24
38
|
@at-root %sprite-map-#{$name}-image-map {
|
25
39
|
background: {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: SassyIcons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pascal Duez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sass
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0.0.
|
33
|
+
version: 1.0.0.rc.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.0.0.
|
40
|
+
version: 1.0.0.rc.1
|
41
41
|
description: Flexible icons system.
|
42
42
|
email:
|
43
43
|
executables: []
|
@@ -56,7 +56,8 @@ files:
|
|
56
56
|
- stylesheets/icons/_icon.scss
|
57
57
|
- stylesheets/icons/_sprite-map-create.scss
|
58
58
|
homepage: http://github.com/pascalduez/SassyIcons
|
59
|
-
licenses:
|
59
|
+
licenses:
|
60
|
+
- MIT
|
60
61
|
metadata: {}
|
61
62
|
post_install_message:
|
62
63
|
rdoc_options: []
|