piecss 0.2.0.0 → 0.3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/piecss.rb +16 -5
- data/sass/piecss/_settings.scss +6 -3
- data/sass/piecss/_utilities.scss +3 -0
- data/sass/piecss/behavior/_anchor.scss +1 -1
- data/sass/piecss/settings/_base.scss +5 -25
- data/sass/piecss/settings/_breakpoint.scss +112 -18
- data/sass/piecss/settings/_button.scss +2 -2
- data/sass/piecss/settings/_colour.scss +152 -0
- data/sass/piecss/settings/_constants.scss +0 -143
- data/sass/piecss/settings/_font.scss +0 -21
- data/sass/piecss/settings/_form.scss +7 -9
- data/sass/piecss/settings/{_grid.scss → _layout.scss} +43 -44
- data/sass/piecss/settings/_list.scss +1 -1
- data/sass/piecss/settings/_miscellaneous.scss +5 -0
- data/sass/piecss/settings/_rhythm.scss +0 -0
- data/sass/piecss/settings/_typography.scss +13 -0
- data/sass/piecss/settings/fonts/_example.scss +36 -36
- data/sass/piecss/settings/fonts/_monospace.scss +33 -33
- data/sass/piecss/settings/fonts/_sans-serif.scss +33 -33
- data/sass/piecss/settings/fonts/_serif.scss +33 -33
- data/sass/piecss/settings/fonts/_verdana.scss +34 -34
- data/sass/piecss/utilities/_breakpoint.scss +5 -5
- data/sass/piecss/utilities/_cache.scss +8 -4
- data/sass/piecss/utilities/_colour.scss +37 -0
- data/sass/piecss/utilities/_element.scss +85 -88
- data/sass/piecss/utilities/_image.scss +20 -22
- data/sass/piecss/utilities/_layout.scss +382 -213
- data/sass/piecss/utilities/_list.scss +2 -0
- data/sass/piecss/utilities/_miscellaneous.scss +161 -99
- data/sass/piecss/utilities/_rhythm.scss +27 -59
- data/sass/piecss/utilities/_side.scss +155 -154
- data/sass/piecss/utilities/_string.scss +68 -0
- data/sass/piecss/utilities/_svg.scss +47 -0
- data/sass/piecss/utilities/_typography.scss +96 -107
- data/sass/piecss/utilities/_unit.scss +85 -50
- data/templates/project/_sets/_button.scss +1 -1
- data/templates/project/_sets/_form.scss +1 -1
- data/templates/project/_sets.scss +1 -1
- data/templates/project/_settings.scss +1 -1
- metadata +13 -40
- data/sass/piecss/settings/fonts/_asap.scss +0 -44
- data/sass/piecss/settings/fonts/_bree-serif.scss +0 -23
- data/sass/piecss/settings/fonts/_lato.scss +0 -32
- data/sass/piecss/settings/fonts/_pt-sans.scss +0 -40
- data/sass/piecss/settings/fonts/_raleway.scss +0 -31
- data/sass/piecss/settings/fonts/_righteous.scss +0 -23
- data/sass/piecss/settings/fonts/_roboto-slab.scss +0 -37
- data/sass/piecss/settings/fonts/_roboto.scss +0 -35
- data/sass/piecss/settings/fonts/_sofia-pro.scss +0 -40
- data/sass/piecss/settings/fonts/_varela-round.scss +0 -24
- data/sass/piecss/settings/fonts/icon-fonts/_fontawesome.scss +0 -33
- data/sass/piecss/settings/fonts/icon-fonts/_foundation-accessability.scss +0 -75
- data/sass/piecss/settings/fonts/icon-fonts/fontawesome/_bootstrap.scss +0 -84
- data/sass/piecss/settings/fonts/icon-fonts/fontawesome/_core.scss +0 -129
- data/sass/piecss/settings/fonts/icon-fonts/fontawesome/_extras.scss +0 -93
- data/sass/piecss/settings/fonts/icon-fonts/fontawesome/_icons.scss +0 -381
- data/sass/piecss/settings/fonts/icon-fonts/fontawesome/_mixins.scss +0 -48
- data/sass/piecss/settings/fonts/icon-fonts/fontawesome/_path.scss +0 -14
- data/sass/piecss/settings/fonts/icon-fonts/fontawesome/_variables.scss +0 -734
- data/sass/piecss/settings/fonts/icon-fonts/foundation-accessability/_settings.scss +0 -28
@@ -26,20 +26,20 @@
|
|
26
26
|
|
27
27
|
@function value-map($values, $keys: $keys-side) {
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
$-list: zip($keys, $values);
|
29
|
+
// Make sure we have all sides, except when a map is used as an argument
|
30
|
+
@if type-of($values) == map {
|
31
|
+
@return $values;
|
32
|
+
}
|
33
|
+
$values: -sides($values);
|
36
34
|
|
37
|
-
|
38
|
-
@each $pair in $-list {
|
39
|
-
$map: map-merge($map, (nth($pair, 1): nth($pair, 2)));
|
40
|
-
}
|
35
|
+
$-list: zip($keys, $values);
|
41
36
|
|
42
|
-
|
37
|
+
$map: ();
|
38
|
+
@each $pair in $-list {
|
39
|
+
$map: map-merge($map, (nth($pair, 1): nth($pair, 2)));
|
40
|
+
}
|
41
|
+
|
42
|
+
@return $map;
|
43
43
|
}
|
44
44
|
|
45
45
|
///
|
@@ -55,20 +55,20 @@
|
|
55
55
|
|
56
56
|
@function is-value-map($values, $keys: $keys-side) {
|
57
57
|
|
58
|
-
|
59
|
-
|
58
|
+
// Start by assuming $values is not a map
|
59
|
+
$is-map: false;
|
60
60
|
|
61
|
-
|
62
|
-
|
61
|
+
// Simple test for a match to $keys, passes if there is a single match
|
62
|
+
@if type-of($values) == map {
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
}
|
64
|
+
@each $key in $keys {
|
65
|
+
@if map-has-key($values, $key) == true {
|
66
|
+
$is-map: true;
|
67
|
+
}
|
69
68
|
}
|
69
|
+
}
|
70
70
|
|
71
|
-
|
71
|
+
@return $is-map;
|
72
72
|
}
|
73
73
|
|
74
74
|
///
|
@@ -86,17 +86,17 @@
|
|
86
86
|
|
87
87
|
@function value-map-to-unit($map, $unit: $unit) {
|
88
88
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
89
|
+
@if not(type-of($map) == map) {
|
90
|
+
@warn "Argument $map needs to be a map.";
|
91
|
+
@return $map;
|
92
|
+
}
|
93
93
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
94
|
+
// Convert to units
|
95
|
+
@each $key, $value in $map {
|
96
|
+
$map: map-merge($map, ($key: to-unit($value, $unit)));
|
97
|
+
}
|
98
98
|
|
99
|
-
|
99
|
+
@return $map;
|
100
100
|
}
|
101
101
|
|
102
102
|
///
|
@@ -113,24 +113,27 @@
|
|
113
113
|
///
|
114
114
|
@function -sides($values) {
|
115
115
|
|
116
|
-
|
117
|
-
|
118
|
-
@return $values;
|
119
|
-
}
|
120
|
-
|
121
|
-
// Check for the number of values and convert to a value map
|
122
|
-
$length: length($values);
|
123
|
-
@if $length==1 {
|
124
|
-
$values: $values $values $values $values;
|
125
|
-
} @elseif $length==2 {
|
126
|
-
$values: nth($values, 1) nth($values, 2) nth($values, 1) nth($values, 2);
|
127
|
-
} @elseif $length==3 {
|
128
|
-
$values: nth($values, 1) nth($values, 2) nth($values, 3) nth($values, 2);
|
129
|
-
} @elseif $length==4 {
|
130
|
-
$values: nth($values, 1) nth($values, 2) nth($values, 3) nth($values, 4);
|
131
|
-
}
|
132
|
-
|
116
|
+
@if type-of($values) == map {
|
117
|
+
@warn "Argument $values needs to be a list or a single value.";
|
133
118
|
@return $values;
|
119
|
+
}
|
120
|
+
|
121
|
+
// Check for the number of values and convert to a value map
|
122
|
+
$length: length($values);
|
123
|
+
@if $length == 1 {
|
124
|
+
$values: $values $values $values $values;
|
125
|
+
}
|
126
|
+
@elseif $length == 2 {
|
127
|
+
$values: nth($values, 1) nth($values, 2) nth($values, 1) nth($values, 2);
|
128
|
+
}
|
129
|
+
@elseif $length == 3 {
|
130
|
+
$values: nth($values, 1) nth($values, 2) nth($values, 3) nth($values, 2);
|
131
|
+
}
|
132
|
+
@elseif $length == 4 {
|
133
|
+
$values: nth($values, 1) nth($values, 2) nth($values, 3) nth($values, 4);
|
134
|
+
}
|
135
|
+
|
136
|
+
@return $values;
|
134
137
|
}
|
135
138
|
|
136
139
|
|
@@ -139,125 +142,123 @@
|
|
139
142
|
|
140
143
|
///
|
141
144
|
/// Mixin padding for any or all sides, in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
|
142
|
-
///
|
145
|
+
///
|
143
146
|
/// @since 0.1
|
144
|
-
///
|
147
|
+
///
|
145
148
|
/// @param {Map} $sides - A spacing map in px (top:0,right:0,bottom:0,left:0)
|
146
149
|
///
|
147
150
|
|
148
151
|
@mixin padding($values) {
|
149
|
-
|
150
|
-
@include -unit-sides($values, padding);
|
152
|
+
@include -unit-sides($values, padding);
|
151
153
|
}
|
152
154
|
|
153
155
|
///
|
154
156
|
/// Mixin top padding in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
|
155
|
-
///
|
157
|
+
///
|
156
158
|
/// @since 0.1
|
157
|
-
///
|
159
|
+
///
|
158
160
|
/// @param {Number} $value - A value in px
|
159
161
|
///
|
160
162
|
|
161
163
|
@mixin padding-top($value) {
|
162
|
-
|
164
|
+
@include -unit-sides((top: $value), padding);
|
163
165
|
}
|
164
166
|
|
165
167
|
///
|
166
168
|
/// Mixin right padding in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
|
167
|
-
///
|
169
|
+
///
|
168
170
|
/// @since 0.1
|
169
|
-
///
|
171
|
+
///
|
170
172
|
/// @param {Number} $value - A value in px
|
171
173
|
///
|
172
174
|
|
173
175
|
@mixin padding-right($value) {
|
174
|
-
|
176
|
+
@include -unit-sides((right: $value), padding);
|
175
177
|
}
|
176
178
|
|
177
179
|
///
|
178
180
|
/// Mixin bottom padding in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
|
179
|
-
///
|
181
|
+
///
|
180
182
|
/// @since 0.1
|
181
|
-
///
|
183
|
+
///
|
182
184
|
/// @param {Number} $value - A value in px
|
183
185
|
///
|
184
186
|
|
185
187
|
@mixin padding-bottom($value) {
|
186
|
-
|
188
|
+
@include -unit-sides((bottom: $value), padding);
|
187
189
|
}
|
188
190
|
|
189
191
|
///
|
190
192
|
/// Mixin left padding in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
|
191
|
-
///
|
193
|
+
///
|
192
194
|
/// @since 0.1
|
193
|
-
///
|
195
|
+
///
|
194
196
|
/// @param {Number} $value - A value in px
|
195
197
|
///
|
196
198
|
|
197
199
|
@mixin padding-left($value) {
|
198
|
-
|
200
|
+
@include -unit-sides((left: $value), padding);
|
199
201
|
}
|
200
202
|
|
201
203
|
|
202
204
|
///
|
203
205
|
/// Mixin margin for any or all sides, in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
|
204
|
-
///
|
206
|
+
///
|
205
207
|
/// @since 0.1
|
206
|
-
///
|
208
|
+
///
|
207
209
|
/// @param {Map} $sides - A spacing map in px (top:0,right:0,bottom:0,left:0)
|
208
210
|
///
|
209
211
|
|
210
212
|
@mixin margin($values) {
|
211
|
-
|
212
|
-
@include -unit-sides($values, margin);
|
213
|
+
@include -unit-sides($values, margin);
|
213
214
|
}
|
214
215
|
|
215
216
|
///
|
216
217
|
/// Mixin top margin in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
|
217
|
-
///
|
218
|
+
///
|
218
219
|
/// @since 0.1
|
219
|
-
///
|
220
|
+
///
|
220
221
|
/// @param {Number} $value - A value in px
|
221
222
|
///
|
222
223
|
|
223
224
|
@mixin margin-top($value) {
|
224
|
-
|
225
|
+
@include -unit-sides((top: $value), margin);
|
225
226
|
}
|
226
227
|
|
227
228
|
///
|
228
229
|
/// Mixin right margin in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
|
229
|
-
///
|
230
|
+
///
|
230
231
|
/// @since 0.1
|
231
|
-
///
|
232
|
+
///
|
232
233
|
/// @param {Number} $value - A value in px
|
233
234
|
///
|
234
235
|
|
235
236
|
@mixin margin-right($value) {
|
236
|
-
|
237
|
+
@include -unit-sides((right: $value), margin);
|
237
238
|
}
|
238
239
|
|
239
240
|
///
|
240
241
|
/// Mixin bottom margin in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
|
241
|
-
///
|
242
|
+
///
|
242
243
|
/// @since 0.1
|
243
|
-
///
|
244
|
+
///
|
244
245
|
/// @param {Number} $value - A value in px
|
245
246
|
///
|
246
247
|
|
247
248
|
@mixin margin-bottom($value) {
|
248
|
-
|
249
|
+
@include -unit-sides((bottom: $value), margin);
|
249
250
|
}
|
250
251
|
|
251
252
|
///
|
252
253
|
/// Mixin right margin in final unit (defaults to em). The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used. With rem fallback if the final unit of output is rem.
|
253
|
-
///
|
254
|
+
///
|
254
255
|
/// @since 0.1
|
255
|
-
///
|
256
|
+
///
|
256
257
|
/// @param {Number} $value - A value in px
|
257
258
|
///
|
258
259
|
|
259
260
|
@mixin margin-left($value) {
|
260
|
-
|
261
|
+
@include -unit-sides((left: $value), margin);
|
261
262
|
}
|
262
263
|
|
263
264
|
|
@@ -275,94 +276,94 @@
|
|
275
276
|
|
276
277
|
@mixin -unit-sides($values, $property: padding, $unit: $unit) {
|
277
278
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
279
|
+
// This mixin needs a value-map to work, so convert argument if it is not a value-map;
|
280
|
+
@if not(is-value-map($values, $keys-side)) {
|
281
|
+
$values: value-map(-sides($values), $keys-side);
|
282
|
+
}
|
283
|
+
|
284
|
+
// now, Convert to units
|
285
|
+
$unit-values: ();
|
286
|
+
@each $key, $value in $values {
|
287
|
+
$unit-values: map-merge($unit-values, ($key: to-unit($value, $unit)));
|
288
|
+
}
|
289
|
+
|
290
|
+
// Now, render the property and include rem fallback if needed
|
291
|
+
@if unit($unit) == rem {
|
292
|
+
@include -sides($values, $property);
|
293
|
+
}
|
294
|
+
@include -sides($unit-values, $property);
|
294
295
|
}
|
295
296
|
|
296
297
|
|
297
298
|
///
|
298
299
|
/// Mixin the value for any or all sides for padding or margin. The mixin will determine if the shorthand notation, or a single side (...-top, ...-right, ...-bottom, --left) should be used.
|
299
|
-
///
|
300
|
+
///
|
300
301
|
/// @access private
|
301
|
-
///
|
302
|
+
///
|
302
303
|
/// @since 0.1
|
303
304
|
///
|
304
305
|
/// @throws 'Argument $map needs to be a value map of four side (top, right, bottom, left) values. Mixin -sides aborted.';
|
305
|
-
///
|
306
|
+
///
|
306
307
|
/// @param {Map} $sides - A spacing map in final values (top:0,right:0,bottom:0,left:0)
|
307
308
|
/// @param {String} $property - The property to apply the values to (padding, margin)
|
308
309
|
///
|
309
310
|
|
310
311
|
@mixin -sides($values, $property: padding) {
|
311
312
|
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
}
|
313
|
+
@if not(is-value-map($values, $keys-side)) {
|
314
|
+
@warn "Argument $map needs to be a value map of four side (top, right, bottom, left) values. Mixin -sides aborted.";
|
315
|
+
}
|
316
|
+
@else {
|
317
|
+
|
318
|
+
// Initialize some variables
|
319
|
+
$top: null;
|
320
|
+
$right: null;
|
321
|
+
$bottom: null;
|
322
|
+
$left: null;
|
323
|
+
|
324
|
+
@if map-has-key($values, top) {
|
325
|
+
$top: map-get($values, top);
|
326
|
+
}
|
327
|
+
|
328
|
+
@if map-has-key($values, right) {
|
329
|
+
$right: map-get($values, right);
|
330
|
+
}
|
331
|
+
|
332
|
+
@if map-has-key($values, bottom) {
|
333
|
+
$bottom: map-get($values, bottom);
|
334
|
+
}
|
335
|
+
|
336
|
+
@if map-has-key($values, left) {
|
337
|
+
$left: map-get($values, left);
|
338
|
+
}
|
339
|
+
|
340
|
+
@if length($values) == 4 {
|
341
|
+
|
342
|
+
@if ($top == $bottom and $right == $left and $top == $right) {
|
343
|
+
#{$property}: #{$top};
|
344
|
+
}
|
345
|
+
@elseif ($top == $bottom and $right == $left) {
|
346
|
+
#{$property}: #{$top} #{$right};
|
347
|
+
}
|
348
|
+
@else {
|
349
|
+
#{$property}: #{$top} #{$right} #{$bottom} #{$left};
|
350
|
+
}
|
351
|
+
|
352
|
+
}
|
353
|
+
@else {
|
354
|
+
|
355
|
+
@if $top {
|
356
|
+
#{$property}-top: #{$top};
|
357
|
+
}
|
358
|
+
@if $right {
|
359
|
+
#{$property}-right: #{$right};
|
360
|
+
}
|
361
|
+
@if $bottom {
|
362
|
+
#{$property}-bottom: #{$bottom};
|
363
|
+
}
|
364
|
+
@if $left {
|
365
|
+
#{$property}-left: #{$left};
|
366
|
+
}
|
367
367
|
}
|
368
|
+
}
|
368
369
|
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
// Copyright (C) 2014 Babs Gösgens. Licensed under MIT; see LICENSE.txt
|
2
|
+
|
3
|
+
|
4
|
+
// Content
|
5
|
+
//
|
6
|
+
// 1. Functions
|
7
|
+
// str-replace
|
8
|
+
// implode
|
9
|
+
|
10
|
+
// 1. FUNCTIONS
|
11
|
+
|
12
|
+
|
13
|
+
///
|
14
|
+
/// Function to replace characters in a string.
|
15
|
+
///
|
16
|
+
/// @example
|
17
|
+
/// @include str-replace('Hello World', 'Hello', 'Yo');
|
18
|
+
///
|
19
|
+
/// @since 1.0
|
20
|
+
///
|
21
|
+
/// @param {String} $string - The whole string
|
22
|
+
/// @param {String} $search - The string that needs to be replaced
|
23
|
+
/// @param {String} $replace - The replacement
|
24
|
+
///
|
25
|
+
|
26
|
+
@function str-replace($string, $search, $replace: "") {
|
27
|
+
|
28
|
+
$index: str-index($string, $search);
|
29
|
+
|
30
|
+
@if $index {
|
31
|
+
@return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
|
32
|
+
}
|
33
|
+
|
34
|
+
@return $string;
|
35
|
+
}
|
36
|
+
|
37
|
+
///
|
38
|
+
/// Function to replace characters in a string.
|
39
|
+
/// http://hugogiraudel.com/2013/08/08/advanced-sass-list-functions/#miscellaneous
|
40
|
+
///
|
41
|
+
/// @example
|
42
|
+
/// $list: a, b, c d e, f, g, h;
|
43
|
+
/// $new-list: implode($list); // abcdefgh
|
44
|
+
/// $new-list: implode($list, '-'); // a-b-c-d-e-f-g-h
|
45
|
+
///
|
46
|
+
/// @since 1.0
|
47
|
+
///
|
48
|
+
/// @param {List} $list - The list to implode
|
49
|
+
/// @param {String} $separator (, ) - A separator to join the list items
|
50
|
+
/// @param {Bool} $is-nested (false) - Set to true is the list is contains other lists
|
51
|
+
///
|
52
|
+
|
53
|
+
@function implode($list, $separator: ', ', $is-nested: false) {
|
54
|
+
$string: null;
|
55
|
+
|
56
|
+
@for $i from 1 through length($list) {
|
57
|
+
$e: nth($list, $i);
|
58
|
+
|
59
|
+
@if type-of($e) == list {
|
60
|
+
$string: $string#{to-string($e, $is-nested, true)};
|
61
|
+
}
|
62
|
+
@else {
|
63
|
+
$string: if($i != length($list) or $is-nested, $string#{$e}#{$separator}, $string#{$e});
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
@return $string;
|
68
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
// Copyright (C) 2014 Babs Gösgens. Licensed under MIT; see LICENSE.txt
|
2
|
+
|
3
|
+
|
4
|
+
// Content
|
5
|
+
//
|
6
|
+
// 1. Functions
|
7
|
+
// svg-url
|
8
|
+
|
9
|
+
|
10
|
+
// 1. FUNCTIONS
|
11
|
+
|
12
|
+
|
13
|
+
///
|
14
|
+
/// Function to create an optimized svg url
|
15
|
+
///
|
16
|
+
/// @example
|
17
|
+
/// @include svg-url('<svg xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M0 0h10v10H0z"/></svg>');
|
18
|
+
///
|
19
|
+
/// @since 1.0
|
20
|
+
///
|
21
|
+
/// @param {String} $svg - The single-line svg xml
|
22
|
+
///
|
23
|
+
|
24
|
+
|
25
|
+
@function svg-url($svg) {
|
26
|
+
//
|
27
|
+
// Chunk up string in order to avoid
|
28
|
+
// "SystemStackError: stack level too deep"
|
29
|
+
//
|
30
|
+
$encoded: "";
|
31
|
+
$slice: 2000;
|
32
|
+
$index: 0;
|
33
|
+
$loops: ceil(str-length($svg) / $slice);
|
34
|
+
|
35
|
+
@for $i from 1 through $loops {
|
36
|
+
$chunk: str-slice($svg, $index, $index + $slice - 1);
|
37
|
+
$chunk: str-replace($chunk, "\"", "'");
|
38
|
+
$chunk: str-replace($chunk, "<", "%3C");
|
39
|
+
$chunk: str-replace($chunk, ">", "%3E");
|
40
|
+
$chunk: str-replace($chunk, "&", "%26");
|
41
|
+
$chunk: str-replace($chunk, "#", "%23");
|
42
|
+
$encoded: #{$encoded}#{$chunk};
|
43
|
+
$index: $index + $slice;
|
44
|
+
}
|
45
|
+
|
46
|
+
@return url("data:image/svg+xml;charset=utf8, #{$encoded}");
|
47
|
+
}
|