compass-icons 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9b645ef8aedc4d6805fd6a3d7e951e5414ea7984
4
+ data.tar.gz: acfde91060f3d89a96401443e74f2aadd9db03dc
5
+ SHA512:
6
+ metadata.gz: 2e882e6194f9a06eb0a17fb69085bbbe48e9162209eb3817090560b948530d326df41e5b0461e5e42a730b1594922d096c33713b04ba499f1accbb7e104e9dff
7
+ data.tar.gz: 8dade80998dfaeddbbaee71dc7c4e6f8a1c1df4472df6f780b46c48c32c0518ef823dbe1f6184c9a553840dd164b36c9f7fa9c44713fd9c2759589cfe937ed29
@@ -0,0 +1,5 @@
1
+ # compass-icons changelog
2
+
3
+ ## 0.1.0 <span style="font-size: .8em">(2015-02-22)</span>
4
+
5
+ ### Refactor
@@ -0,0 +1,181 @@
1
+ # compass-icons
2
+
3
+ Flexible compass plugin for working with icons (SVG, PNG).
4
+
5
+ Works on top of compass sprite API.
6
+ It was designed to easily switch between SVG and PNG while working with icons as background-images.
7
+ So you have more granular control over which icons to use as SVG or PNG.
8
+ SVG first with PNG sprite fallback, or PNG first with hidpi sprite support.
9
+
10
+ Also managing several "thematic" sprites a breeze.
11
+
12
+
13
+ *Best workflow used in conjunction with [grunt-svg2png](https://github.com/pascalduez/grunt-svg2png).*
14
+
15
+ *Online [preview](http://pascalduez.github.io/SassyIcons/test) (test folder).*
16
+ *Online [Documentation](http://pascalduez.github.io/SassyIcons/docs) (generated with SassDoc).*
17
+
18
+ ## API
19
+
20
+ `sprite-map-create($name [, $spacing])`
21
+ `icon($map, $sprite [, $offset, $format])`
22
+ `icon-single($map, $sprite [, $format])`
23
+ `icon-generated($map, $sprite [, $pos, $centered, $format])`
24
+
25
+
26
+ ## Usage
27
+
28
+ ### Requirements
29
+
30
+ * Sass ~> 3.3.0
31
+ * Compass ~> 1.0.0.rc.1
32
+
33
+ ### Installation
34
+
35
+ #### Git
36
+
37
+ ```
38
+ git clone git@github.com:pascalduez/SassyIcons.git
39
+ ```
40
+
41
+ #### npm
42
+
43
+ ```
44
+ npm install sassyicons --save
45
+ ```
46
+
47
+ #### Bower
48
+
49
+ ```
50
+ bower install SassyIcons --save
51
+ ```
52
+
53
+ #### Compass extension
54
+
55
+ Since SassyIcons is dependant on Compass, this is the recommended installation and usage.
56
+
57
+ 1. Add `gem 'SassyIcons', '~>0.1.0'` to your `Gemfile`
58
+ 2. `bundle install --path .` (manage your gems in project dir, not globally)
59
+ 3. Add `require 'SassyIcons'` to your `config.rb`
60
+ 4. Import it in your stylesheets with `@import 'SassyIcons'`
61
+
62
+ ### Configuration
63
+
64
+ ```scss
65
+ // Default settings.
66
+ $icons-defaults: (
67
+
68
+ // Space around sprites in generated spritemap.
69
+ // Useful with `$offset` parameter.
70
+ // This setting is global for all spritemaps.
71
+ // Can be set per spritemap with the `$spacing` parameter.
72
+ spacing: 0,
73
+
74
+ // Main icons directory. `sprite-map-create()`, base for sub dirs.
75
+ dir: "icons",
76
+
77
+ // Name of the png sub-folders.
78
+ dir-png: "png",
79
+
80
+ // Name of the hidpi png sub-folders.
81
+ dir-hidpi: "png_2x",
82
+
83
+ // Scale of the hidpi pngs.
84
+ hidpi-scale: 2,
85
+
86
+ // Minimum resolution ratio used in the hidpi media query.
87
+ hidpi-ratio: 1.3,
88
+
89
+ // Whether to embed icons as data URI in the `icon-single()` mixin.
90
+ single-embed: true,
91
+
92
+ // Default file format unless overridden by parameter, svg | png.
93
+ format: "svg",
94
+
95
+ // Whether to support legacy browsers, svg fallback.
96
+ legacy: true
97
+
98
+ );
99
+ ```
100
+ Override default values in a new `$icons-settings` map.
101
+
102
+
103
+ ## Usage
104
+
105
+ #### Example usage with [Compass](http://compass-style.org/help/tutorials/command-line)
106
+ ```scss
107
+ // Import SassyIcons.
108
+ @import 'SassyIcons';
109
+
110
+ // Instantiate a new sprite-map from folder `icons/social`.
111
+ @include sprite-map-create(social, $spacing: 10px);
112
+
113
+ .icon--twitter {
114
+ @include icon(social, "twitter");
115
+ }
116
+
117
+ .icon--twitter {
118
+ @include icon-generated(social, "twitter", $format: "png");
119
+ }
120
+
121
+ ```
122
+ ```
123
+ bundle exec compass watch
124
+ ```
125
+
126
+
127
+ ## Roadmap
128
+
129
+ * More documentation
130
+ * `icon-generated()` and `generated()` Don't force absolute positioning.
131
+ * Rewrite `generated()` mixin
132
+ * `icon-generated()` configurable `calc()` fallback
133
+ * Helper mixin to work with `background-size`
134
+ * Support for SVG sprites ?
135
+ * Support for SVG stacks ?
136
+ * Try to further improve output CSS
137
+ * More control over print position in the stylesheet ?
138
+ * Abstract and move away from Compass sprites ?
139
+ * Move away from Modernizr classes ? Or make it an option.
140
+ * Clarify or remove the `@content` thing to pass additional rules to `.svg`.
141
+
142
+ ## Future
143
+
144
+ This library used to address a specific need, at a specific moment. Although one
145
+ of its main feature is to bring granular control on how many icons you want to
146
+ inline, keep in mind that too many inlined SVG's, especially base64 encoded might
147
+ be a concern for performances.
148
+
149
+ There are a bunch of different techniques to integrate SVG icons, that you should
150
+ check out and evaluate before deciding on any.
151
+
152
+ Some (non exaustive) resources:
153
+ * [Different ways of using icons ](https://github.com/betravis/icon-methods)
154
+ * [An Overview of SVG Sprite Creation Techniques](http://24ways.org/2014/an-overview-of-svg-sprite-creation-techniques)
155
+ * [Tips For Optimising SVG Delivery For The Web](http://calendar.perfplanet.com/2014/tips-for-optimising-svg-delivery-for-the-web)
156
+
157
+
158
+ ## Development
159
+
160
+ ### You need
161
+
162
+ * [Node.js](http://nodejs.org)
163
+ * [Ruby](https://www.ruby-lang.org)
164
+ * [Bundler](http://bundler.io) via `gem install bundler`
165
+ * `grunt-cli` via `npm install -g grunt-cli`
166
+
167
+ ### How to
168
+
169
+ 1. Fork this repository
170
+ 2. Run `npm install`
171
+ 3. Make your changes + write tests
172
+ 4. `grunt test`
173
+
174
+ ## Authors
175
+
176
+ [Pascal Duez](http://pascalduez.me)
177
+
178
+
179
+ ## Licence
180
+
181
+ SassyIcons is available under the [MIT](http://opensource.org/licenses/MIT) license.
@@ -0,0 +1,4 @@
1
+ require 'compass'
2
+
3
+ extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
4
+ Compass::Frameworks.register('compass-icons', :path => extension_path)
@@ -0,0 +1,30 @@
1
+ // -----------------------------------------------------------------------------
2
+ // compass-icons - Flexible icons system.
3
+ // -----------------------------------------------------------------------------
4
+ // Repository: https://github.com/reactivestudio/compass-icons
5
+ // -----------------------------------------------------------------------------
6
+
7
+ // A bit of terminology:
8
+ // sprite = a single image/icon
9
+ // 'sprite-sheet' or 'sprite-map' == all sprites combined together
10
+
11
+ //
12
+ // Import configuration
13
+ //
14
+ @import "config/config";
15
+
16
+ //
17
+ // Import helpers
18
+ //
19
+ @import "helpers/helpers";
20
+
21
+ //
22
+ // Import icons
23
+ //
24
+ @import "icons/sprite-map-create";
25
+ @import "icons/icon";
26
+ @import "icons/icon-single";
27
+ @import "icons/generated";
28
+ @import "icons/icon-generated";
29
+ @import "icons/pseudo-generated";
30
+ @import "icons/icon-pseudo";
@@ -0,0 +1,92 @@
1
+
2
+ // compass-icons: configuration
3
+ // -------------------------
4
+
5
+
6
+ ////
7
+ //// @group config
8
+ ////
9
+
10
+
11
+ /// Default settings.
12
+ ///
13
+ /// @type Map
14
+ ///
15
+ /// @prop {Number} spacing (0) - Space around sprites in generated spritemap
16
+ /// @prop {String} dir ('icons') - Main icons directory. `sprite-map-create()`, base for sub dirs
17
+ /// @prop {String} dir-png ('png') - Name of the png sub-folders
18
+ /// @prop {String} dir-hidpi ('png_2x') - Name of the hidpi png sub-folders
19
+ /// @prop {Number} hidpi-scale (2) - Scale of the hidpi pngs
20
+ /// @prop {Number} hidpi-ratio (1.3) - Minimum resolution ratio used in the hidpi media query
21
+ /// @prop {Boolean} single-embed (true) - Whether to embed icons as data URI in the `icon-single()` mixin
22
+ /// @prop {String} format ('svg') - Default file format unless overridden by parameter, svg | png
23
+ /// @prop {Boolean} legacy (true) - Whether to support legacy browsers, svg fallback
24
+
25
+ $icons-defaults: (
26
+
27
+ // Space around sprites in generated spritemap.
28
+ // Useful with `$offset` parameter.
29
+ // This setting is global for all spritemaps.
30
+ // Can be set per spritemap with the `$spacing` parameter.
31
+ spacing: 0,
32
+
33
+ // Main icons directory. `sprite-map-create()`, base for sub dirs.
34
+ dir: "icons",
35
+
36
+ // Name of the png sub-folders.
37
+ dir-png: "png",
38
+
39
+ // Name of the hidpi png sub-folders.
40
+ dir-hidpi: "png_2x",
41
+
42
+ // Scale of the hidpi pngs.
43
+ hidpi-scale: 2,
44
+
45
+ // Minimum resolution ratio used in the hidpi media query.
46
+ hidpi-ratio: 1.3,
47
+
48
+ // Whether to embed icons as data URI in the `icon-single()` mixin.
49
+ single-embed: true,
50
+
51
+ // Default file format unless overridden by parameter, svg | png.
52
+ format: "svg",
53
+
54
+ // Whether to support legacy browsers, svg fallback.
55
+ legacy: true
56
+
57
+ );
58
+
59
+
60
+ /// User settings.
61
+ /// Instanciate the same object in your stylesheets to override defaults.
62
+ ///
63
+ /// @type Map
64
+ ///
65
+ /// @example scss Override defaults
66
+ /// $icons-settings: (
67
+ /// dir: "assets",
68
+ /// hidpi-scale: 3
69
+ /// );
70
+
71
+ $icons-settings: () !default;
72
+
73
+
74
+ /// Retrieve a configuration item.
75
+ ///
76
+ /// @access private
77
+ ///
78
+ /// @requires {variable} icons-defaults
79
+ /// @requires {variable} icons-settings
80
+ ///
81
+ /// @param {String} $key - configuration item key
82
+ ///
83
+ /// @return {*}
84
+
85
+ @function conf($key) {
86
+ @if not map-has-key($icons-defaults, $key) {
87
+ @warn "No item `#{$key}` found in configuration.";
88
+ @return false;
89
+ }
90
+
91
+ @return map-get(map-merge($icons-defaults, $icons-settings), $key);
92
+ }
@@ -0,0 +1,96 @@
1
+
2
+ // compass-icons: helpers
3
+ // -------------------
4
+
5
+
6
+ ////
7
+ //// @group helpers
8
+ //// @access private
9
+ ////
10
+
11
+
12
+ /// Helper: join `$list` into a string.
13
+ ///
14
+ /// @param {List} $list - the list to convert
15
+ /// @param {String} $glue ('') - a string to separate each element of the list
16
+ ///
17
+ /// @return {String}
18
+
19
+ @function _join(
20
+ $list,
21
+ $glue: ''
22
+ ) {
23
+ $length: length($list);
24
+ $result: '';
25
+
26
+ @if $length < 1 {
27
+ @return $result;
28
+ }
29
+
30
+ @for $i from 1 through $length {
31
+ $result: $result
32
+ + nth($list, $i)
33
+ + if($i != $length, $glue, '');
34
+ }
35
+
36
+ @return $result;
37
+ }
38
+
39
+
40
+ /// Helper: retrieve a spritemap.
41
+ ///
42
+ /// @requires {variable} icons-spritemaps
43
+ ///
44
+ /// @param {String} $name - spritemap name
45
+ /// @param {String} $factor (1x) - dpi factor
46
+ ///
47
+ /// @return {Spritemap}
48
+
49
+ @function _sprite-map-get(
50
+ $name,
51
+ $factor: 1x
52
+ ) {
53
+ @return map-get(map-get($icons-spritemaps, $name), $factor);
54
+ }
55
+
56
+
57
+ /// Helper: return correct spritemap `background-position`.
58
+ ///
59
+ /// @requires Compass::sprite-position
60
+ ///
61
+ /// @param {Spritemap} $map - spritemap name
62
+ /// @param {String} $sprite - sprite name
63
+ /// @param {Number} $offset-x (0) - adjustment along the x axis
64
+ /// @param {Number} $offset-y (0) - adjustment along the y axis
65
+ /// @param {Number} $scale (1) - spritemap scale
66
+ ///
67
+ /// @return {List} (x-pos y-pos)
68
+
69
+ @function _sprite-position(
70
+ $map,
71
+ $sprite,
72
+ $offset-x: 0,
73
+ $offset-y: 0,
74
+ $scale: 1
75
+ ) {
76
+ $pos: sprite-position($map, $sprite, $offset-x, $offset-y * $scale);
77
+ @return (nth($pos, 1) nth($pos, 2) / $scale);
78
+ }
79
+
80
+
81
+ /// Hidpi media query builder.
82
+ ///
83
+ /// @link http://bjango.com/articles/min-device-pixel-ratio/
84
+ /// @link http://brettjankord.com/2012/11/28/cross-browser-retinahigh-resolution-media-queries
85
+ /// @link http://w3.org/blog/CSS/2012/06/14/unprefix-webkit-device-pixel-ratio
86
+
87
+ @mixin hidpi-mq {
88
+ $hidpi-ratio: conf(hidpi-ratio);
89
+
90
+ @media (-webkit-min-device-pixel-ratio: $hidpi-ratio),
91
+ (min-resolution: round($hidpi-ratio * 96dpi)),
92
+ (min-resolution: $hidpi-ratio * 1dppx)
93
+ {
94
+ @content;
95
+ }
96
+ }
@@ -0,0 +1,39 @@
1
+
2
+ // compass-icons: generated
3
+ // ---------------------
4
+
5
+
6
+ /// Boilerplate styles for generated content `:before` or `:after`.
7
+ ///
8
+ /// @access private
9
+ /// @group helpers
10
+ /// @todo Rewrite that crap
11
+ ///
12
+ /// @param {Number} $width
13
+ /// @param {Number} $height
14
+ /// @param {Number} $top
15
+ /// @param {Number} $right
16
+ /// @param {Number} $bottom
17
+ /// @param {Number} $left
18
+
19
+ @mixin generated(
20
+ $width: false,
21
+ $height: false,
22
+ $top: false,
23
+ $right: false,
24
+ $bottom: false,
25
+ $left: false
26
+ ) {
27
+ @if $width { width: $width };
28
+ @if $height { height: $height };
29
+ content: "";
30
+ display: block;
31
+ position: absolute;
32
+ @if $top { top: $top; }
33
+ @if $right { right: $right; }
34
+ @if $bottom { bottom: $bottom; }
35
+ @if $left { left: $left; }
36
+ z-index: 1;
37
+
38
+ @content;
39
+ }
@@ -0,0 +1,56 @@
1
+
2
+ // compass-icons: icon-generated
3
+ // --------------------------
4
+
5
+
6
+ /// Include the icon in a generated pseudo-element.
7
+ /// Default to `:before`.
8
+ /// Allows for easier positioning or centering.
9
+ ///
10
+ /// @group icons
11
+ ///
12
+ /// @requires conf
13
+ /// @requires _sprite-map-get
14
+ /// @requires {mixin} generated
15
+ /// @requires {mixin} icon
16
+ /// @requires Compass::sprite-file
17
+ /// @requires Compass::image-width
18
+ /// @requires Compass::image-height
19
+ ///
20
+ /// @param {String} $map - spritemap name
21
+ /// @param {String} $sprite - sprite name
22
+ /// @param {String} $pos ('before') - pseudo-element position
23
+ /// @param {Bool} $centered (false) - whether to center the icon, relative to its parent
24
+ /// @param {String} $format (conf(format)) - file format 'svg' | 'png'
25
+ ///
26
+ /// @output Cross-browser icon as background-image.
27
+
28
+ @mixin icon-generated(
29
+ $map,
30
+ $sprite,
31
+ $pos: 'before',
32
+ $centered: false,
33
+ $format: conf(format)
34
+ ) {
35
+ position: relative;
36
+
37
+ &:#{$pos} {
38
+ $sprite-file: sprite-file(_sprite-map-get($map), $sprite);
39
+
40
+ $width: image-width($sprite-file);
41
+ $height: image-height($sprite-file);
42
+
43
+ @include generated($width, $height);
44
+
45
+ @if $centered {
46
+ top: 35%;
47
+ top: calc(50% - #{$height} / 2);
48
+ left: 35%;
49
+ left: calc(50% - #{$width} / 2);
50
+ }
51
+
52
+ @include icon($map: $map, $sprite: $sprite, $format: $format);
53
+
54
+ @content;
55
+ }
56
+ }
@@ -0,0 +1,62 @@
1
+
2
+ // compass-icons: icon-pseudo
3
+ // --------------------------
4
+
5
+
6
+ /// Include the icon in a generated pseudo-element.
7
+ /// Default to `:before`.
8
+ /// Allows for easier positioning or centering.
9
+ ///
10
+ /// @group icons
11
+ ///
12
+ /// @requires conf
13
+ /// @requires _sprite-map-get
14
+ /// @requires {mixin} generated
15
+ /// @requires {mixin} icon
16
+ /// @requires Compass::sprite-file
17
+ /// @requires Compass::image-width
18
+ /// @requires Compass::image-height
19
+ ///
20
+ /// @param {String} $map - spritemap name
21
+ /// @param {String} $sprite - sprite name
22
+ /// @param {String} $pos ('before') - pseudo-element position
23
+ /// @param {Bool} $centered (false) - whether to center the icon, relative to its parent
24
+ /// @param {String} $format (conf(format)) - file format 'svg' | 'png'
25
+ ///
26
+ /// @output Cross-browser icon as background-image.
27
+
28
+ @mixin icon-pseudo(
29
+ $map,
30
+ $sprite,
31
+ $position: "left",
32
+ $valign: middle,
33
+ $margin: 10px,
34
+ $hover: false
35
+ $centered: false,
36
+ $format: conf(format)
37
+ ) {
38
+ $pseudo: "after";
39
+ @if $position == "left" or $position == "top" {
40
+ $pseudo: "before";
41
+ }
42
+ $sprite-file: sprite-file(_sprite-map-get($map), $sprite);
43
+ $width: image-width($png-file);
44
+ $height: image-height($png-file);
45
+
46
+ .icon--#{$sprite} {
47
+ &:#{$pseudo} {
48
+ @include pseudo-genereted($width, $height, $position, $valign, $margin);
49
+ @include icon($map: $map, $sprite: $sprite, $format: $format);
50
+ }
51
+
52
+ @if $hover == true {
53
+ &:hover:#{$pseudo} {
54
+ $sprite: $sprite + "--hover";
55
+ @include pseudo-genereted($width, $height, $position, $valign, $margin);
56
+ @include icon($map: $map, $sprite: $sprite, $format: $format);
57
+ }
58
+ }
59
+
60
+ @content;
61
+ }
62
+ }
@@ -0,0 +1,81 @@
1
+
2
+ // compass-icons: icon-single
3
+ // -----------------------
4
+
5
+
6
+ /// Embed a single icon as inline-image (no spritemap).
7
+ /// Should be used sporadically.
8
+ ///
9
+ /// @group icons
10
+ ///
11
+ /// @requires conf
12
+ /// @requires _join
13
+ /// @requires Compass::inline-image
14
+ /// @requires Compass::inline-url
15
+ /// @requires Compass::image-width
16
+ /// @requires {mixin} hidpi-mq
17
+ ///
18
+ /// @param {String} $map - spritemap name
19
+ /// @param {String} $sprite - sprite name
20
+ /// @param {String} $format (conf(format)) - file format 'svg' | 'png'
21
+ ///
22
+ /// @output Cross-browser icon as background-image
23
+
24
+ @mixin icon-single(
25
+ $map,
26
+ $sprite,
27
+ $format: conf(format)
28
+ ) {
29
+
30
+ // sprite-file() and inline-image() no work.
31
+ // @see https://github.com/chriseppstein/compass/issues/951
32
+
33
+ $dir: conf(dir);
34
+ $svg-file: _join(($dir, $map, '#{$sprite}.svg'), '/');
35
+ $png-file-1x: _join(($dir, $map, conf(dir-png), '#{$sprite}.png'), '/');
36
+ $png-file-2x: _join(($dir, $map, conf(dir-hidpi), '#{$sprite}.png'), '/');
37
+
38
+ $function: if(conf(single-embed), inline-image, image-url);
39
+ $svg-url: call($function, $svg-file);
40
+ $png-url-1x: call($function, $png-file-1x);
41
+ $png-url-2x: call($function, $png-file-2x);
42
+
43
+ $legacy-support: conf(legacy);
44
+
45
+ // Allow to pass format as uppercase.
46
+ $format: to-lower-case($format);
47
+
48
+ @if $format == 'svg' {
49
+
50
+ background: {
51
+ image: $svg-url;
52
+ repeat: no-repeat;
53
+ }
54
+
55
+ .svg & {
56
+ @content;
57
+ }
58
+
59
+ @if $legacy-support {
60
+ .no-svg &,
61
+ .no-js & {
62
+ background-image: $png-url-1x;
63
+ }
64
+ }
65
+
66
+ }
67
+ @else if $format == 'png' {
68
+
69
+ background: {
70
+ image: $png-url-1x;
71
+ repeat: no-repeat;
72
+ }
73
+
74
+ @include hidpi-mq {
75
+ background: {
76
+ image: $png-url-2x;
77
+ size: ceil(image-width($png-file-2x) / conf(hidpi-scale)) auto;
78
+ }
79
+ }
80
+ }
81
+ }
@@ -0,0 +1,84 @@
1
+
2
+ // compass-icons: icon
3
+ // ----------------
4
+
5
+
6
+ /// Main icon mixin,
7
+ /// default choice unless there are specific needs.
8
+ ///
9
+ /// @group icons
10
+ ///
11
+ /// @requires conf
12
+ /// @requires _sprite-map-get
13
+ /// @requires _join
14
+ /// @requires _sprite-position
15
+ /// @requires Compass::inline-image
16
+ /// @requires {mixin} hidpi-mq
17
+ ///
18
+ /// @param {String} $map - spritemap name
19
+ /// @param {String} $sprite - sprite name
20
+ /// @param {List} $offset ((0 0)) - adjustment along the x y axis
21
+ /// @param {String} $format (conf(format)) - file format 'svg' | 'png'
22
+ ///
23
+ /// @example scss Include an icon
24
+ /// .twitter {
25
+ /// @include icon(social, twitter);
26
+ /// }
27
+ ///
28
+ /// @output Cross-browser icon as background-image
29
+
30
+ @mixin icon(
31
+ $map,
32
+ $sprite,
33
+ $offset: 0 0,
34
+ $format: conf(format)
35
+ ) {
36
+ $map-1x: _sprite-map-get($map);
37
+ $map-2x: _sprite-map-get($map, 2x);
38
+
39
+ // Shorter mixin calls.
40
+ $offset-x: nth($offset, 1);
41
+ $offset-y: nth($offset, length($offset));
42
+
43
+ $legacy-support: conf(legacy);
44
+
45
+ // Allow to pass format as uppercase.
46
+ $format: to-lower-case($format);
47
+
48
+ @if $format == 'svg' {
49
+
50
+ $svg-file: _join((conf(dir), $map, '#{$sprite}.svg'), '/');
51
+
52
+ background: {
53
+ image: inline-image($svg-file);
54
+ repeat: no-repeat;
55
+ }
56
+
57
+ .svg & {
58
+ @content;
59
+ }
60
+
61
+ @if $legacy-support {
62
+ .no-svg &,
63
+ .no-js & {
64
+
65
+ @extend %sprite-map-#{$map}-image-map;
66
+
67
+ background-position: _sprite-position($map-1x, $sprite, $offset-x, $offset-y);
68
+ }
69
+ }
70
+
71
+ }
72
+ @else if $format == 'png' {
73
+
74
+ @extend %sprite-map-#{$map}-image-map;
75
+
76
+ background-position: _sprite-position($map-1x, $sprite, $offset-x, $offset-y);
77
+
78
+ @extend %sprite-map-#{$map}-2x-image-map;
79
+
80
+ @include hidpi-mq {
81
+ background-position: _sprite-position($map-2x, $sprite, $offset-x, $offset-y, conf(hidpi-scale));
82
+ }
83
+ }
84
+ }
@@ -0,0 +1,42 @@
1
+
2
+ // compass-icons: pseudo-generated
3
+ // ---------------------
4
+
5
+
6
+ /// Boilerplate styles for generated content `:before` or `:after`.
7
+ ///
8
+ /// @access private
9
+ /// @group helpers
10
+ /// @todo Rewrite that crap
11
+ ///
12
+ /// @param {Number} $width
13
+ /// @param {Number} $height
14
+ /// @param {Number} $top
15
+ /// @param {Number} $right
16
+ /// @param {Number} $bottom
17
+ /// @param {Number} $left
18
+
19
+ @mixin pseudo-generated(
20
+ $width,
21
+ $height,
22
+ $position,
23
+ $valign,
24
+ $margin
25
+ ) {
26
+ width: $width;
27
+ height: $height;
28
+
29
+ content: "";
30
+ position: relative;
31
+ @if $position == "left" or $position == "right" {
32
+ display: inline-block;
33
+ vertical-align: $valign;
34
+ } @else {
35
+ display: block;
36
+ }
37
+
38
+ margin: $margin;
39
+ z-index: 1;
40
+
41
+ @content;
42
+ }
@@ -0,0 +1,62 @@
1
+
2
+ // compass-icons: sprite-map-create
3
+ // -----------------------------
4
+
5
+
6
+ ////
7
+ //// @group icons
8
+ ////
9
+
10
+
11
+ /// Spritemaps storage.
12
+ ///
13
+ /// @access private
14
+ /// @type Map
15
+
16
+ $icons-spritemaps: ();
17
+
18
+
19
+ /// Create a new spritemap from folder.
20
+ ///
21
+ /// @requires conf
22
+ /// @requires _join
23
+ /// @requires {mixin} hidpi-mq
24
+ /// @requires {variable} icons-spritemaps
25
+ /// @requires Compass::sprite-map
26
+ /// @requires Compass::sprite-path
27
+ /// @requires Compass::image-width
28
+ ///
29
+ /// @param {String} $name - spritemap name, which is also the folder name
30
+ /// @param {Number} $spacing (conf(spacing)) - Whether to add space around sprites in generated spritemap
31
+ ///
32
+ /// @example scss Instantiate a new sprite map
33
+ /// @include sprite-map-create(social, $spacing: 30px);
34
+
35
+ @mixin sprite-map-create(
36
+ $name,
37
+ $spacing: conf(spacing)
38
+ ) {
39
+ $sprites-1x: _join((conf(dir), $name, conf(dir-png), "*.png"), "/");
40
+ $sprites-2x: _join((conf(dir), $name, conf(dir-hidpi), "*.png"), "/");
41
+
42
+ $map-1x: sprite-map($sprites-1x, $spacing: $spacing);
43
+ $map-2x: sprite-map($sprites-2x, $spacing: $spacing);
44
+
45
+ $new: ($name: (1x: $map-1x, 2x: $map-2x));
46
+ $icons-spritemaps: map-merge($icons-spritemaps, $new) !global;
47
+
48
+ @at-root %sprite-map-#{$name}-image-map {
49
+ background: {
50
+ image: $map-1x;
51
+ repeat: no-repeat;
52
+ }
53
+ }
54
+ @at-root %sprite-map-#{$name}-2x-image-map {
55
+ @include hidpi-mq {
56
+ background: {
57
+ image: $map-2x;
58
+ size: ceil(image-width(sprite-path($map-2x)) / conf(hidpi-scale)) auto;
59
+ }
60
+ }
61
+ }
62
+ }
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: compass-icons
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dmitriy Bushin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sass
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: compass
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0.rc.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.0.rc.1
41
+ description: Compass plugin for icons
42
+ email:
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - README.md
48
+ - CHANGELOG.md
49
+ - lib/compass-icons.rb
50
+ - scss/_compass-icons.scss
51
+ - scss/config/_config.scss
52
+ - scss/helpers/_helpers.scss
53
+ - scss/icons/_generated.scss
54
+ - scss/icons/_icon-generated.scss
55
+ - scss/icons/_icon-pseudo.scss
56
+ - scss/icons/_icon-single.scss
57
+ - scss/icons/_icon.scss
58
+ - scss/icons/_pseudo-genereted.scss
59
+ - scss/icons/_sprite-map-create.scss
60
+ homepage: https://github.com/reactivestudio/compass-icons
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 1.3.6
78
+ requirements: []
79
+ rubyforge_project: compass-icons
80
+ rubygems_version: 2.1.5
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Flexible compass plugin for working with icons (SVG, PNG)
84
+ test_files: []