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
@@ -1,100 +1,80 @@
1
1
  // Container Syntax
2
2
  // ================
3
3
 
4
+ // Container [mixin]
5
+ // -----------------
4
6
  // Set a container element
7
+ // - [$grid] : <settings>
5
8
  @mixin container(
6
- $container: get-container()
9
+ $grid: get-grid()
7
10
  ) {
8
- $container : parse-container($container);
9
- $grid : parse-grid(nth($container,1));
10
- $justify : nth($container,2);
11
- $show : nth($container,3);
12
- $box : get-setting(box-sizing, $grid);
13
-
14
- // if there is a container width, use it
15
- $width : get-setting(container, $grid);
11
+ $grid : get-adjusted-grid($grid);
16
12
 
17
- @if not $width {
18
- // if we have a column width, calculate container from that
19
- $column-width-setting: get-setting(column-width, $grid);
20
-
21
- @if $column-width-setting {
22
- $columns-setting: get-setting(columns, $grid);
23
- $gutters-setting: get-setting(gutters, $grid);
24
- $outer: if(get-setting(gutter-placement, $grid) == inside, true, false);
25
-
26
- $width: calculate-container-width($columns-setting, $gutters-setting, $column-width-setting, $outer);
27
- } @else {
28
- // if we have nothing, default to 100%
29
- $width: 100%;
30
- }
31
- }
13
+ $this-container : get-setting(container, $grid);
14
+ $this-column-width : get-setting(column-width, $grid);
15
+ $this-columns : get-setting(columns, $grid);
16
+ $this-gutters : get-setting(gutters, $grid);
17
+ $this-gutter-position : get-setting(gutter-position, $grid);
18
+ $this-layout-math : get-setting(layout-math, $grid);
32
19
 
33
- @if $show and $show != hide {
34
- @include grid-background($grid);
35
- }
20
+ $width : get-container-width($this-container, $this-column-width, $this-columns, $this-gutters, $this-gutter-position);
21
+ $justify : get-setting(container-position, $grid);
22
+ $box : get-setting(box-sizing, $grid);
36
23
 
37
- @if $box == border-box {
38
- @include box-sizing(border-box);
39
- } @else if $box == content-box {
40
- @include box-sizing(content-box);
24
+ @if $box {
25
+ @include box-sizing($box);
41
26
  }
42
27
 
43
- @include float-container($width, $justify, $show);
28
+ @include float-container($width, $justify, $this-layout-math);
29
+ @include grid-background($grid);
44
30
  }
45
31
 
46
- // Container Helpers
47
- // -----------------
48
-
49
- // Get the current container-related settings
50
- @function get-container(
32
+ // Container [function]
33
+ // --------------------
34
+ // Return container width
35
+ // - [$grid] : <settings>
36
+ @function container(
37
+ $grid: get-grid()
51
38
  ) {
52
- $show: false;
39
+ $grid : get-adjusted-grid($grid);
53
40
 
54
- // Create keyword for show-grids setting
55
- @if $show-grids and $show-grids != "hide" {
56
- $show: show;
57
- } @else {
58
- $show: hide;
59
- }
41
+ $this-container : get-setting(container, $grid);
42
+ $this-column-width : get-setting(column-width, $grid);
43
+ $this-columns : get-setting(columns, $grid);
44
+ $this-gutters : get-setting(gutters, $grid);
45
+ $this-gutter-position : get-setting(gutter-position, $grid);
60
46
 
61
- @return get-grid() $container-position $show;
47
+ $width: get-container-width($this-container, $this-column-width, $this-columns, $this-gutters, $this-gutter-position);
48
+
49
+ @return $width;
62
50
  }
63
51
 
64
- // parse the container shorthand syntax, and return an ordered list
65
- @function parse-container(
66
- $container: get-container()
52
+ // Get Container Width
53
+ // -------------------
54
+ // Calculate the container width
55
+ // - [$container] : <length> | false
56
+ // - [$column-width] : <length> | false
57
+ // - [$columns] : <columns>
58
+ // - [$gutters] : <ratio>
59
+ // - [$gutter-position] : before | after | split | inside
60
+ @function get-container-width(
61
+ $container : $container,
62
+ $column-width : $column-width,
63
+ $columns : $columns,
64
+ $gutters : $gutters,
65
+ $gutter-position : $gutter-position
67
66
  ) {
68
- $grid : false;
69
- $justify : $container-position;
70
- $show : $show-grids;
71
-
72
- // justify: left | center | right
73
- @if index($container, left) {
74
- $justify: left;
75
- $container: filter($container, left);
76
- } @else if index($container, center) {
77
- $justify: center;
78
- $container: filter($container, center);
79
- } @else if index($container, right) {
80
- $justify: right;
81
- $container: filter($container, right);
82
- }
67
+ $width: $container;
83
68
 
84
- // show-grids: show | hide
85
- @if index($container, show) {
86
- $show: true;
87
- $container: filter($container, show);
88
- } @else if index($container, hide) {
89
- $show: false;
90
- $container: filter($container, hide);
91
- }
92
-
93
- @if length($container) == 1 {
94
- $grid: nth($container,1);
95
- } @else {
96
- $grid: $container;
69
+ @if not $width or $width == auto {
70
+ @if $column-width {
71
+ $outer: if($gutter-position == inside, true, false);
72
+ $width: calculate-container-width($columns, $gutters, $column-width, $outer);
73
+ } @else {
74
+ // if we have nothing, default to 100%
75
+ $width: 100%;
76
+ }
97
77
  }
98
78
 
99
- @return $grid $justify $show;
79
+ @return $width;
100
80
  }
@@ -1,92 +1,71 @@
1
1
  // Gallery Syntax
2
2
  // ==============
3
3
 
4
- // Create a gallery
4
+ // Gallery
5
+ // -------
6
+ // Create an isolated gallery
7
+ // - $input : <span>
8
+ // - [$selector] : child | of-type
5
9
  @mixin gallery(
6
10
  $input,
7
11
  $selector: child
8
12
  ) {
9
- $this-isolate: get-span-setting(isolate, $input, parse);
10
-
11
- @if $this-isolate {
12
- @include isolate-gallery($input);
13
- } @else {
14
- @include nth-gallery($input);
13
+ $input : parse-span($input);
14
+ $width : null;
15
+ $location : 1;
16
+
17
+ $span : get-span-setting(span, $input);
18
+ $this-columns : get-span-setting(columns, $input);
19
+ $this-gutters : get-span-setting(gutters, $input);
20
+ $this-column-width : get-span-setting(column-width, $input);
21
+ $this-layout-math : get-span-setting(layout-math, $input);
22
+ $this-gutter-position : get-span-setting(gutter-position, $input);
23
+ $this-flow : get-span-setting(flow, $input);
24
+
25
+ $box : get-span-setting(box-sizing, $input);
26
+ $inside : if(get-span-setting(gutter-position, $input) == inside, true, false);
27
+
28
+ $from : from($this-flow);
29
+ $context : column-count($this-columns);
30
+ $line : floor($context / $span);
31
+
32
+ $padding-before : null;
33
+ $padding-after : null;
34
+
35
+ @if $inside {
36
+ $inside-gutter: get-gutters($this-columns, $this-gutters, $this-column-width, $this-layout-math, $this-gutter-position);
37
+ $padding-before: nth($inside-gutter, 1);
38
+ $padding-after: nth($inside-gutter, 2);
15
39
  }
16
- }
17
-
18
- // Gallery Helpers
19
- // ---------------
20
-
21
- // Create a floated gallery
22
- @mixin nth-gallery(
23
- $input,
24
- $selector: child
25
- ) {
26
- $this-input : parse-span($input);
27
-
28
- $span : get-span-setting(span, $this-input);
29
- $this-columns : get-span-setting(columns, $this-input);
30
- $context : column-count($this-columns);
31
- $line : floor($context / $span);
32
-
33
- @if is-symmetrical($this-columns) {
34
- @include span($input);
35
- @include nth-first('#{$line}n + 1');
36
- @include nth-last('#{$line}n');
37
- } @else {
38
- $location : 1;
39
-
40
- @for $item from 1 through $line {
41
- $nth: '#{$line}n + #{$item}';
42
- &:#{format-nth($nth,$selector)} {
43
- $location-input: join($input, at $location);
44
-
45
- @include span($location-input);
46
40
 
47
- $location: $location + $span;
48
- @if $location > $context { $location: 1; }
49
- }
50
- }
41
+ @if $box == border-box or $inside {
42
+ @include box-sizing(border-box);
43
+ } @else if $box == content-box {
44
+ @include box-sizing(content-box);
51
45
  }
52
- }
53
-
54
- // Create an isolated gallery
55
- @mixin isolate-gallery(
56
- $input,
57
- $selector: child
58
- ) {
59
- $input : parse-span($input);
60
- $width : null;
61
- $location : 1;
62
-
63
- $span : get-span-setting(span, $input);
64
- $this-columns : get-span-setting(columns, $input);
65
- $this-gutters : get-span-setting(gutters, $input);
66
- $this-column-width : get-span-setting(column-width, $input);
67
- $this-static : get-span-setting(static, $input);
68
- $this-flow : get-span-setting(flow, $input);
69
-
70
- $from : from($this-flow);
71
- $context : column-count($this-columns);
72
- $line : floor($context / $span);
73
46
 
74
47
  @if is-symmetrical($this-columns) {
75
- $width: get-span-width($span, $location, $this-columns, $this-gutters, $this-column-width, $this-static);
48
+ $width: get-span-width($span, $location, $this-columns, $this-gutters, $this-column-width, $this-layout-math);
76
49
  }
77
50
 
78
- @include float-span-output($width, $from, null, -100%, null, null, $this-flow);
51
+ @include float-span-output($width, from, null, -100%, $padding-before, $padding-after, $this-flow);
79
52
 
80
53
  @for $item from 1 through $line {
81
54
  $nth: '#{$line}n + #{$item}';
82
55
  &:#{format-nth($nth,$selector)} {
83
- $width: get-span-width($span, $location, $this-columns, $this-gutters, $this-column-width, $this-static);
56
+ $width: get-span-width($span, $location, $this-columns, $this-gutters, $this-column-width, $this-layout-math);
84
57
  $width: if(is-symmetrical($columns), null, $width);
85
- $before: get-isolation($span, $location, $this-columns, $this-gutters, $this-column-width, $this-static);
58
+ $before: get-isolation($span, $location, $this-columns, $this-gutters, $this-column-width, $this-layout-math);
86
59
 
87
60
  @include float-span-output($width, null, $before, null, null, null, $this-flow);
88
61
 
89
- @if $location == 1 { clear: $from; }
62
+ @if is-first($location) {
63
+ @include first;
64
+ clear: $from;
65
+ } @else {
66
+ clear: none;
67
+ }
68
+
90
69
  $location: $location + $span;
91
70
  @if $location > $context { $location: 1; }
92
71
  }
@@ -0,0 +1,117 @@
1
+ // Gutter Syntax
2
+ // =============
3
+
4
+ // Gutters
5
+ // -------
6
+ // Set gutters on an element.
7
+ // - [$context] : <settings>
8
+ @mixin gutters(
9
+ $context: get-grid()
10
+ ) {
11
+ $context: get-adjusted-grid($context);
12
+
13
+ $this-columns : get-setting(columns, $context);
14
+ $this-gutters : get-setting(gutters, $context);
15
+ $this-column-width : get-setting(column-width, $context);
16
+ $this-layout-math : get-setting(layout-math, $context);
17
+ $this-gutter-position : get-setting(gutter-position, $context);
18
+ $this-flow : get-setting(flow, $context);
19
+
20
+ $from: from($this-flow);
21
+ $to: to($this-flow);
22
+
23
+ $this-gutters: get-gutters($this-columns, $this-gutters, $this-column-width, $this-layout-math, $this-gutter-position);
24
+ $property: if($this-gutter-position == inside, padding, margin);
25
+
26
+ #{$property}-#{$from}: nth($this-gutters, 1);
27
+ #{$property}-#{$to}: nth($this-gutters, 2);
28
+ }
29
+
30
+ // Gutter
31
+ // ------
32
+ // Return the width of a gutter.
33
+ // - [$context] : <settings>
34
+ @function gutter(
35
+ $context: get-grid()
36
+ ) {
37
+ $context : get-adjusted-grid($context);
38
+
39
+ $this-columns : get-setting(columns, $context);
40
+ $this-gutters : get-setting(gutters, $context);
41
+ $this-column-width : get-setting(column-width, $context);
42
+ $this-layout-math : get-setting(layout-math, $context);
43
+ $this-gutter-position : get-setting(gutter-position, $context);
44
+
45
+ $width: get-gutter-width($this-columns, $this-gutters, $this-column-width, $this-layout-math);
46
+
47
+ @if $this-gutter-position == inside or $this-gutter-position == split {
48
+ $width: $width / 2;
49
+ }
50
+
51
+ @return $width;
52
+ }
53
+
54
+ // Get Gutter Width
55
+ // ----------------
56
+ // Return gutter width.
57
+ // - [$columns] : <number> | <list>
58
+ // - [$gutters] : <ratio>
59
+ // - [$column-width] : <length>
60
+ // - [$layout-math] : fluid | static
61
+ @function get-gutter-width(
62
+ $columns : $columns,
63
+ $gutters : $gutters,
64
+ $column-width : $column-width,
65
+ $layout-math : $layout-math
66
+ ) {
67
+ $context : column-sum($columns, $gutters);
68
+ $gutter : null;
69
+
70
+ @if $layout-math == static {
71
+ $gutter: $gutters * $column-width;
72
+ } @else {
73
+ $gutter: percentage($gutters / $context);
74
+ }
75
+
76
+ @return $gutter;
77
+ }
78
+
79
+ // Get Gutters
80
+ // -----------
81
+ // Return before and after gutter values.
82
+ // - [$columns] : <number> | <list>
83
+ // - [$gutters] : <ratio>
84
+ // - [$column-width] : <length>
85
+ // - [$layout-math] : fluid | static
86
+ // - [$gutter-position] : before | after |split | inside
87
+ // - [$gutter-override] : <length>
88
+ @function get-gutters(
89
+ $columns : $columns,
90
+ $gutters : $gutters,
91
+ $column-width : $column-width,
92
+ $layout-math : $layout-math,
93
+ $gutter-position : $gutter-position,
94
+ $gutter-override : false
95
+ ) {
96
+ $gutter : null;
97
+ $before : null;
98
+ $after : null;
99
+
100
+ @if $gutter-override {
101
+ $gutter: $gutter-override;
102
+ } @else {
103
+ $gutter: get-gutter-width($columns, $gutters, $column-width, $layout-math);
104
+ }
105
+
106
+ @if $gutter-position == before {
107
+ $before: $gutter;
108
+ } @else if $gutter-position == after {
109
+ $after: $gutter;
110
+ } @else if $gutter-position == split or $gutter-position == inside {
111
+ $gutter: if($gutter-override, $gutter, $gutter / 2);
112
+ $before: $gutter;
113
+ $after: $gutter;
114
+ }
115
+
116
+ @return $before $after;
117
+ }
@@ -1,7 +1,10 @@
1
1
  // Isolation Syntax
2
2
  // ================
3
3
 
4
- // Isolation Override
4
+ // Isolate
5
+ // -------
6
+ // Set isolation as an override.
7
+ // - $input : <span>
5
8
  @mixin isolate(
6
9
  $input
7
10
  ) {
@@ -12,26 +15,30 @@
12
15
  $this-columns : get-span-setting(columns, $input);
13
16
  $this-gutters : get-span-setting(gutters, $input);
14
17
  $this-column-width : get-span-setting(column-width, $input);
15
- $this-static : get-span-setting(static, $input);
18
+ $this-layout-math : get-span-setting(layout-math, $input);
16
19
  $this-flow : get-span-setting(flow, $input);
17
20
 
18
- $push: get-isolation($span, $location, $columns, $gutters, $column-width, $static);
21
+ $push: get-isolation($span, $location, $columns, $gutters, $column-width, $layout-math);
19
22
 
20
- @include isolate-output($push,$this-flow);
23
+ @include isolate-output($push, $this-flow);
21
24
  }
22
25
 
23
- // Isolation Helpers
24
- // -----------------
25
-
26
- // Return the isolation position
26
+ // Get Isolation
27
+ // -------------
28
+ // Return the isolation offset width
29
+ // - $span : <length> | <number>
30
+ // - $location : <number>
31
+ // - [$columns] : <number> | <list>
32
+ // - [$gutters] : <ratio>
33
+ // - [$column-width] : <length>
34
+ // - [$layout-math] : fluid | static
27
35
  @function get-isolation(
28
36
  $span,
29
37
  $location,
30
- $columns : $columns,
31
- $gutters : $gutters,
32
- $column-width : $column-width,
33
- $static : $static,
34
- $gutter-place : $gutter-placement
38
+ $columns : $columns,
39
+ $gutters : $gutters,
40
+ $column-width : $column-width,
41
+ $layout-math : $layout-math
35
42
  ) {
36
43
  $context : column-sum($columns, $gutters);
37
44
  $width : null;
@@ -41,7 +48,7 @@
41
48
  } @else {
42
49
  $push: get-location-position($span, $location, $columns) - 1;
43
50
  @if $push > 0 {
44
- $width: get-span-width($push, 1, $columns, $gutters, $column-width, $static, $gutter-place, outer);
51
+ $width: get-span-width($push, 1, $columns, $gutters, $column-width, $layout-math, $outer: outer);
45
52
  } @else {
46
53
  $width: null;
47
54
  }