susy 2.0.0.alpha.2 → 2.0.0.alpha.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/lib/susy.rb +0 -10
  3. data/sass/_susy.scss +2 -2
  4. data/sass/susy/_core.scss +3 -3
  5. data/sass/susy/_helpers.scss +2 -3
  6. data/sass/susy/_math.scss +2 -2
  7. data/sass/susy/_settings.scss +4 -39
  8. data/sass/susy/api/_float.scss +2 -2
  9. data/sass/susy/api/_shared.scss +2 -2
  10. data/sass/susy/api/float/_container.scss +9 -5
  11. data/sass/susy/api/float/_end.scss +8 -4
  12. data/sass/susy/api/float/_isolate.scss +7 -3
  13. data/sass/susy/api/float/_span.scss +18 -4
  14. data/sass/susy/api/shared/_container.scss +10 -6
  15. data/sass/susy/api/shared/_grid-background.scss +30 -7
  16. data/sass/susy/api/shared/_margins.scss +9 -5
  17. data/sass/susy/api/shared/_padding.scss +9 -5
  18. data/sass/susy/helpers/_direction.scss +11 -1
  19. data/sass/susy/helpers/_nth.scss +4 -0
  20. data/sass/susy/language/_shared.scss +2 -3
  21. data/sass/susy/language/_susy.scss +5 -4
  22. data/sass/susy/language/shared/_context.scss +10 -9
  23. data/sass/susy/language/shared/_settings.scss +181 -101
  24. data/sass/susy/language/susy/_background.scss +84 -75
  25. data/sass/susy/language/susy/_container.scss +57 -77
  26. data/sass/susy/language/susy/_gallery.scss +46 -67
  27. data/sass/susy/language/susy/_gutters.scss +117 -0
  28. data/sass/susy/language/susy/_isolate.scss +21 -14
  29. data/sass/susy/language/susy/_margins.scss +92 -0
  30. data/sass/susy/language/susy/_padding.scss +68 -0
  31. data/sass/susy/language/susy/_rows.scss +43 -15
  32. data/sass/susy/language/susy/_span.scss +198 -61
  33. data/sass/susy/language/susy1/_settings.scss +13 -23
  34. data/sass/susy/math/_columns.scss +26 -3
  35. data/sass/susy/math/_container.scss +17 -12
  36. data/sass/susy/math/_location.scss +13 -0
  37. metadata +8 -35
  38. data/sass/susy/helpers/_sass-lists.scss +0 -90
  39. data/sass/susy/language/susy/_functions.scss +0 -58
  40. data/sass/susy/language/susy/_math.scss +0 -153
@@ -0,0 +1,92 @@
1
+ // Margin Syntax
2
+ // =============
3
+
4
+ // Pre
5
+ // ---
6
+ // Add spanning-margins before an element.
7
+ // - $span : <span>
8
+ @mixin pre(
9
+ $span
10
+ ) {
11
+ $span : if(index($span, outer), $span, append($span, outer));
12
+ $flow : get-span-setting(flow, $span, parse);
13
+ $width : span($span);
14
+
15
+ @include margin-output($width, null, $flow);
16
+ }
17
+
18
+ // Post
19
+ // ----
20
+ // Add spanning-margins after an element.
21
+ // - $span : <span>
22
+ @mixin post(
23
+ $span
24
+ ) {
25
+ $span : if(index($span, outer), $span, append($span, outer));
26
+ $flow : get-span-setting(flow, $span, parse);
27
+ $width : span($span);
28
+
29
+ @include margin-output(null, $width, $flow);
30
+ }
31
+
32
+ // Push
33
+ // ----
34
+ // Simple synonymn for pre.
35
+ // - $span : <span>
36
+ @mixin push(
37
+ $span
38
+ ) {
39
+ @include pre($span);
40
+ }
41
+
42
+ // Pull
43
+ // ----
44
+ // Add negative spanning-margins before an element.
45
+ // - $span : <span>
46
+ @mixin pull(
47
+ $span
48
+ ) {
49
+ $span : if(index($span, outer), $span, append($span, outer));
50
+ $flow : get-span-setting(flow, $span, parse);
51
+ $width : 0 - span($span);
52
+
53
+ @include margin-output($width, null, $flow);
54
+ }
55
+
56
+ // Squish
57
+ // ------
58
+ // Add spanning-margins before and after an element.
59
+ // - $pre : <span>
60
+ // - [$post] : <span>
61
+ @mixin squish(
62
+ $pre,
63
+ $post: $pre
64
+ ) {
65
+ $pre : if(index($pre, outer), $pre, append($pre, outer));
66
+ $post : if(index($post, outer), $post, append($post, outer));
67
+
68
+ $get-pre : parse-span($pre);
69
+ $get-post : parse-span($post);
70
+
71
+ $flow : get-span-setting(flow, $get-pre);
72
+ $before : null;
73
+ $after : null;
74
+
75
+ // get the various contexts
76
+ $default-context : $columns $gutters;
77
+ $pre-context : get-span-setting(columns, $get-pre) get-span-setting(gutters, $get-pre);
78
+ $post-context : get-span-setting(columns, $get-post) get-span-setting(gutters, $get-post);
79
+
80
+ // if the contexts don't line up, and only the post has changed, we use it for both
81
+ @if $pre-context != $post-context and $default-context == $pre-context {
82
+ @include use-grid($post-context) {
83
+ $before: span($pre);
84
+ $after: span($post);
85
+ }
86
+ } @else {
87
+ $before: span($pre);
88
+ $after: span($post);
89
+ }
90
+
91
+ @include margin-output($before, $after, $flow);
92
+ }
@@ -0,0 +1,68 @@
1
+ // Padding Syntax
2
+ // ==============
3
+
4
+ // Prefix
5
+ // ------
6
+ // Add spanning-padding before an element.
7
+ // - $span : <span>
8
+ @mixin prefix(
9
+ $span
10
+ ) {
11
+ $span : if(index($span, outer), $span, append($span, outer));
12
+ $flow : get-span-setting(flow, $span, parse);
13
+ $width : span($span);
14
+
15
+ @include padding-output($width, null, $flow);
16
+ }
17
+
18
+ // Suffix
19
+ // ------
20
+ // Add spanning-padding after an element.
21
+ // - $span : <span>
22
+ @mixin suffix(
23
+ $span
24
+ ) {
25
+ $span : if(index($span, outer), $span, append($span, outer));
26
+ $flow : get-span-setting(flow, $span, parse);
27
+ $width : span($span);
28
+
29
+ @include padding-output(null, $width, $flow);
30
+ }
31
+
32
+ // Pad
33
+ // ---
34
+ // Add spanning-padding before and after an element.
35
+ // - $pre : <span>
36
+ // - [$post] : <span>
37
+ @mixin pad(
38
+ $pre,
39
+ $post: $pre
40
+ ) {
41
+ $pre : if(index($pre, outer), $pre, append($pre, outer));
42
+ $post : if(index($post, outer), $post, append($post, outer));
43
+
44
+ $get-pre : parse-span($pre);
45
+ $get-post : parse-span($post);
46
+
47
+ $flow : get-span-setting(flow, $get-pre);
48
+ $before : null;
49
+ $after : null;
50
+
51
+ // get the various contexts
52
+ $default-context : $columns $gutters;
53
+ $pre-context : get-span-setting(columns, $get-pre) get-span-setting(gutters, $get-pre);
54
+ $post-context : get-span-setting(columns, $get-post) get-span-setting(gutters, $get-post);
55
+
56
+ // if the contexts don't line up, and only the post has changed, we use it for both
57
+ @if $pre-context != $post-context and $default-context == $pre-context {
58
+ @include use-grid($post-context) {
59
+ $before: span($pre);
60
+ $after: span($post);
61
+ }
62
+ } @else {
63
+ $before: span($pre);
64
+ $after: span($post);
65
+ }
66
+
67
+ @include padding-output($before, $after, $flow);
68
+ }
@@ -1,46 +1,63 @@
1
1
  // Row Start & End
2
2
  // ===============
3
3
 
4
+ // Row
5
+ // ---
4
6
  // Apply to any layout element that should force a new layout row.
7
+ // - [$flow] : ltr | rtl
5
8
  @mixin row(
6
9
  $flow: $flow
7
10
  ) {
8
- $clear: $flow;
9
-
10
- @if $flow == ltr or $flow == rtl {
11
- $clear: from($flow);
12
- }
13
-
14
- clear: $clear;
11
+ @include pie-clearfix;
12
+ clear: from($flow);
15
13
  }
16
14
 
15
+ // Unrow
16
+ // -----
17
17
  // Cancel the row() effect, e.g. when using media queries.
18
+ // - [$flow] : ltr | rtl
18
19
  @mixin unrow {
19
20
  clear: none;
21
+ &:after {
22
+ content: none;
23
+ display: inline;
24
+ clear: none;
25
+ }
20
26
  }
21
27
 
22
- // First item
23
- // ----------
24
-
28
+ // First
29
+ // -----
30
+ // - [$flow] : ltr | rtl
25
31
  @mixin first(
26
32
  $flow: $flow
27
33
  ) {
28
34
  @include float-first($flow);
29
35
  }
30
36
 
37
+ // Alpha
38
+ // -----
39
+ // - [$flow] : ltr | rtl
31
40
  @mixin alpha(
32
41
  $flow: $flow
33
42
  ) {
34
43
  @include float-first($flow);
35
44
  }
36
45
 
46
+ // Nth-First
47
+ // ---------
48
+ // - [$value] : first | last | only | <math>
49
+ // - [$type] : child | last-child | of-type | last-of-type
37
50
  @mixin nth-first(
38
51
  $value: first,
39
52
  $type: child
40
53
  ) {
41
- &:#{format-nth($value,$type)} { @include first($flow); }
54
+ &:#{format-nth($value,$type)} { @include first(); }
42
55
  }
43
56
 
57
+ // Nth-Alpha
58
+ // ---------
59
+ // - [$value] : first | last | only | <math>
60
+ // - [$type] : child | last-child | of-type | last-of-type
44
61
  @mixin nth-alpha(
45
62
  $value: first,
46
63
  $type: child
@@ -48,28 +65,39 @@
48
65
  @include nth-first($value, $type);
49
66
  }
50
67
 
51
- // Last item
52
- // ---------
53
-
68
+ // Last
69
+ // ----
70
+ // - [$flow] : ltr | rtl
54
71
  @mixin last(
55
72
  $flow: $flow
56
73
  ) {
57
74
  @include float-last($flow);
58
75
  }
59
76
 
77
+ // Omega
78
+ // -----
79
+ // - [$flow] : ltr | rtl
60
80
  @mixin omega(
61
81
  $flow: $flow
62
82
  ) {
63
83
  @include float-last($flow);
64
84
  }
65
85
 
86
+ // Nth-Last
87
+ // --------
88
+ // - [$value] : first | last | only | <math>
89
+ // - [$type] : child | last-child | of-type | last-of-type
66
90
  @mixin nth-last(
67
91
  $value: last,
68
92
  $type: child
69
93
  ) {
70
- &:#{format-nth($value,$type)} { @include last($flow); }
94
+ &:#{format-nth($value,$type)} { @include last(); }
71
95
  }
72
96
 
97
+ // Nth-Omega
98
+ // ---------
99
+ // - [$value] : first | last | only | <math>
100
+ // - [$type] : child | last-child | of-type | last-of-type
73
101
  @mixin nth-omega(
74
102
  $value: last,
75
103
  $type: child
@@ -1,14 +1,17 @@
1
- // Span language parsing
2
- // =====================
1
+ // Span Syntax
2
+ // ===========
3
3
 
4
- // Set a spanning element using shorthand syntax
4
+ // Span [mixin]
5
+ // ------------
6
+ // Set a spanning element using shorthand syntax.
7
+ // - $span : <span>
5
8
  @mixin span(
6
9
  $span
7
10
  ) {
8
11
  $span : parse-span($span);
9
12
  $output : span-math($span...);
10
13
  $box : get-span-setting(box-sizing, $span);
11
- $inside : if(get-span-setting(gutter-placement, $span) == inside, true, false);
14
+ $inside : if(get-span-setting(gutter-position, $span) == inside, true, false);
12
15
 
13
16
  @if $box == border-box or $inside {
14
17
  @include box-sizing(border-box);
@@ -19,26 +22,51 @@
19
22
  @include float-span-output($output...);
20
23
  }
21
24
 
22
- // Span Helpers
23
- // ------------
25
+ // Span [function]
26
+ // ---------------
27
+ // Return the width of a span.
28
+ // - $span : <span>
29
+ @function span(
30
+ $span
31
+ ) {
32
+ $span : parse-span($span);
33
+
34
+ $width : get-span-setting(span, $span);
35
+
36
+ $this-location : get-span-setting(location, $span);
37
+ $this-columns : get-span-setting(columns, $span);
38
+ $this-gutters : get-span-setting(gutters, $span);
39
+ $this-column-width : get-span-setting(column-width, $span);
40
+ $this-layout-math : get-span-setting(layout-math, $span);
41
+ $this-gutter-position : get-span-setting(gutter-position, $span);
42
+ $outer : get-span-setting(outer, $span);
24
43
 
25
- // Parse the span shortcut syntax
44
+ $width: get-span-width($width, $this-location, $this-columns, $this-gutters, $this-column-width, $this-layout-math, $this-gutter-position, $outer);
45
+
46
+ @return $width;
47
+ }
48
+
49
+ // Parse Span
50
+ // ----------
51
+ // Parse the span shortcut syntax.
52
+ // - $string : <span>
26
53
  @function parse-span(
27
54
  $string
28
55
  ) {
29
- $new-span : false;
30
- $new-location : false;
31
- $new-context : false;
32
- $new-isolate : false;
33
- $new-static : false;
34
- $new-columns : false;
35
- $new-gutters : false;
36
- $new-column-width : false;
37
- $new-flow : false;
38
- $new-gutter-place : false;
39
- $gutter-override : false;
40
-
41
- $is-container : false;
56
+ $new-span : false;
57
+ $new-location : false;
58
+ $new-context : false;
59
+ $new-layout-method : false;
60
+ $new-layout-math : false;
61
+ $new-columns : false;
62
+ $new-gutters : false;
63
+ $new-column-width : false;
64
+ $outer : false;
65
+ $new-flow : false;
66
+ $new-gutter-position : false;
67
+ $gutter-override : false;
68
+
69
+ $is-container : false;
42
70
 
43
71
  $i: 1;
44
72
 
@@ -58,18 +86,23 @@
58
86
  $new-location: last;
59
87
  }
60
88
 
61
- // isolate
89
+ // layout-method
62
90
  @else if $value == isolate {
63
- $new-isolate: isolate;
91
+ $new-layout-method: isolate;
64
92
  } @else if $value == float {
65
- $new-isolate: float;
93
+ $new-layout-method: float;
66
94
  }
67
95
 
68
- // static | fluid
96
+ // layout-math | fluid
69
97
  @else if $value == static {
70
- $new-static: static;
98
+ $new-layout-math: static;
71
99
  } @else if $value == fluid {
72
- $new-static: fluid;
100
+ $new-layout-math: fluid;
101
+ }
102
+
103
+ // ltr | rtl
104
+ @else if $value == outer {
105
+ $outer: outer;
73
106
  }
74
107
 
75
108
  // ltr | rtl
@@ -81,19 +114,19 @@
81
114
 
82
115
  // after | before | split | inside | no-gutters
83
116
  @else if $value == after {
84
- $new-gutter-place: after;
117
+ $new-gutter-position: after;
85
118
  } @else if $value == before {
86
- $new-gutter-place: before;
119
+ $new-gutter-position: before;
87
120
  } @else if $value == split {
88
- $new-gutter-place: split;
121
+ $new-gutter-position: split;
89
122
  } @else if $value == inside {
90
- $new-gutter-place: inside;
91
- } @else if $value == no-gutters {
92
- $new-gutter-place: no-gutters;
123
+ $new-gutter-position: inside;
124
+ } @else if $value == no-gutter or $value == no-gutters {
125
+ $new-gutter-position: no-gutters;
93
126
  }
94
127
 
95
128
  // container
96
- @if $value == container {
129
+ @else if $value == container {
97
130
  $is-container: container;
98
131
  }
99
132
 
@@ -132,7 +165,7 @@
132
165
  // context
133
166
  @if $of {
134
167
  $i: $i + 1;
135
- $new-context: compact();
168
+ $new-context: ();
136
169
 
137
170
  @while $of and $i <= length($string) {
138
171
  $this: nth($string,$i);
@@ -151,44 +184,36 @@
151
184
 
152
185
  // parse the context
153
186
  @if $new-context {
154
- $new-columns: get-setting(columns, $new-context);
155
- $new-gutters: get-setting(gutters, $new-context);
156
- $new-column-width: get-setting(column-width, $new-context);
187
+ $new-context : parse-grid($new-context);
188
+ $new-columns : get-setting(columns, $new-context);
189
+ $new-gutters : get-setting(gutters, $new-context);
190
+ $new-column-width : get-setting(column-width, $new-context);
157
191
  }
158
192
 
159
193
  // use global values for empty grid settings
160
- @if not $new-columns {
161
- $new-columns: $columns;
162
- }
163
- @if not $new-gutters {
164
- $new-gutters: $gutters;
165
- }
166
- @if not $new-column-width {
167
- $new-column-width: $column-width;
168
- }
169
- @if not $new-static {
170
- $new-static: $static;
171
- }
172
- @if not $new-isolate {
173
- $new-isolate: $isolate;
174
- }
175
- @if not $new-flow {
176
- $new-flow: $flow;
177
- }
178
- @if not $new-gutter-place {
179
- $new-gutter-place: $gutter-placement;
180
- }
194
+ $new-columns : if($new-columns, $new-columns, $columns);
195
+ $new-gutters : if($new-gutters, $new-gutters, $gutters);
196
+ $new-column-width : if($new-column-width, $new-column-width, $column-width);
197
+ $new-layout-math : if($new-layout-math, $new-layout-math, $layout-math);
198
+ $new-layout-method : if($new-layout-method, $new-layout-method, $layout-method);
199
+ $new-flow : if($new-flow, $new-flow, $flow);
200
+ $new-gutter-position : if($new-gutter-position, $new-gutter-position, $gutter-position);
181
201
 
182
- @return $new-span $new-location $new-columns $new-gutters $new-column-width $new-isolate $new-static $new-flow $new-gutter-place $is-container $gutter-override;
202
+ @return $new-span, $new-location, $new-columns, $new-gutters, $new-column-width, $new-layout-method, $new-layout-math, $outer, $new-flow, $new-gutter-position, $is-container, $gutter-override;
183
203
  }
184
204
 
185
- // Return one particular span setting from a list
205
+ // Get Span Setting
206
+ // ----------------
207
+ // Return one particular span setting from a list.
208
+ // - $setting : <keyword> (see $options below)
209
+ // - $span : <span>
210
+ // - $parse : <boolean>
186
211
  @function get-span-setting(
187
212
  $setting,
188
213
  $span,
189
214
  $parse: false
190
215
  ) {
191
- $options : span location columns gutters column-width isolate static flow gutter-placement is-container gutter-override;
216
+ $options : span location columns gutters column-width layout-method layout-math outer flow gutter-position is-container gutter-override;
192
217
  $key : index($options, $setting);
193
218
  $value : false;
194
219
 
@@ -202,3 +227,115 @@
202
227
 
203
228
  @return $value;
204
229
  }
230
+
231
+ // Span Math
232
+ // ---------
233
+ // Get all the span results.
234
+ // - $span : <length> | <number>
235
+ // - $location : first | last | <length> | <number>
236
+ // - [$columns] : <number> | <list>
237
+ // - [$gutters] : <ratio>
238
+ // - [$column-width] : <length>
239
+ // - [$layout-method] : float | isolate
240
+ // - [$layout-math] : fluid | static
241
+ // - [$outer] : <boolean>
242
+ // - [$flow] : ltr | rtl
243
+ // - [$gutter-position] : before | after | split | inside
244
+ // - [$is-container] : <boolean>
245
+ // - [$gutter-override] : <length>
246
+ @function span-math(
247
+ $span,
248
+ $location,
249
+ $columns : $columns,
250
+ $gutters : $gutters,
251
+ $column-width : $column-width,
252
+ $layout-method : $layout-method,
253
+ $layout-math : $layout-math,
254
+ $outer : $outer,
255
+ $flow : $flow,
256
+ $gutter-position : $gutter-position,
257
+ $is-container : false,
258
+ $gutter-override : false
259
+ ) {
260
+ $float : from;
261
+ $width : $span;
262
+
263
+ $padding-before : null;
264
+ $padding-after : null;
265
+ $margin-before : null;
266
+ $margin-after : null;
267
+
268
+ // calculate widths
269
+ $width: get-span-width($span, $location, $columns, $gutters, $column-width, $layout-math, $gutter-position, $outer);
270
+ $this-gutters: get-gutters($columns, $gutters, $column-width, $layout-math, $gutter-position, $gutter-override);
271
+
272
+ // apply gutters
273
+ @if $gutter-position == inside and not $is-container {
274
+ $padding-before: nth($this-gutters,1);
275
+ $padding-after: nth($this-gutters,2);
276
+ } @else if $gutter-position != inside {
277
+ $margin-before: nth($this-gutters,1);
278
+ $margin-after: nth($this-gutters,2);
279
+ }
280
+
281
+ // special margin handling
282
+ @if $layout-method == isolate {
283
+ $margin-before: get-isolation($span, $location, $columns, $gutters, $column-width, $layout-math);
284
+ $margin-after: -100%;
285
+ } @else {
286
+ @if is-last($span, $location, $columns) {
287
+ $float: to;
288
+ $margin-after: null;
289
+ } @else if is-first($location) {
290
+ $margin-before: null;
291
+ }
292
+ }
293
+
294
+ @return $width $float $margin-before $margin-after $padding-before $padding-after $flow;
295
+ }
296
+
297
+ // Get Span Width
298
+ // --------------
299
+ // Return span width.
300
+ // - $span : <length> | <number>
301
+ // - $location : first | last | <length> | <number>
302
+ // - [$columns] : <number> | <list>
303
+ // - [$gutters] : <ratio>
304
+ // - [$column-width] : <length>
305
+ // - [$layout-math] : fluid | static
306
+ // - [$gutter-position] : before | after | split | inside
307
+ // - [$outer] : <boolean>
308
+ @function get-span-width(
309
+ $span,
310
+ $location : 1,
311
+ $columns : $columns,
312
+ $gutters : $gutters,
313
+ $column-width : $column-width,
314
+ $layout-math : $layout-math,
315
+ $gutter-position : $gutter-position,
316
+ $outer : null
317
+ ) {
318
+ $context : null;
319
+ $span-sum : null;
320
+ $width : null;
321
+
322
+ @if unitless($span) {
323
+ @if $gutter-position == inside {
324
+ $context: column-sum($columns, $gutters, outer);
325
+ $span-sum: get-column-span-sum($span, $location, $columns, $gutters, outer);
326
+ } @else {
327
+ $context: column-sum($columns, $gutters);
328
+ $span-sum: get-column-span-sum($span, $location, $columns, $gutters, $outer);
329
+ }
330
+
331
+ @if $layout-math == static {
332
+ $width: $span-sum * $column-width;
333
+ } @else {
334
+ $width: percentage($span-sum / $context);
335
+ }
336
+ } @else {
337
+ $width: $span;
338
+ }
339
+
340
+ @return $width;
341
+ }