singularitygs 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/singularitygs.rb CHANGED
@@ -4,6 +4,6 @@ require 'breakpoint'
4
4
  Compass::Frameworks.register("singularitygs", :path => "#{File.dirname(__FILE__)}/..")
5
5
 
6
6
  module SingularityGS
7
- VERSION = "1.0.1"
8
- DATE = "2013-04-02"
7
+ VERSION = "1.0.2"
8
+ DATE = "2013-04-03"
9
9
  end
@@ -17,7 +17,7 @@ $gutters: () !default;
17
17
  $mobile-first: true;
18
18
 
19
19
  // Default output style.
20
- $output: 'float' !default;
20
+ $output: 'isolation' !default;
21
21
 
22
22
  // Direction for your grid. Can be ltr, rtl, or both
23
23
  $direction: 'ltr' !default;
@@ -1,3 +1,4 @@
1
1
  @import "math/columns";
2
2
  @import "math/gutters";
3
- @import "math/context";
3
+ @import "math/context";
4
+ @import "math/span";
@@ -14,6 +14,8 @@
14
14
 
15
15
  $gutter: find-gutter($gutter);
16
16
  $end-row: end-row($span, $location, $columns);
17
+ $start-row: start-row($location);
18
+
17
19
 
18
20
  width: column-span($span, $location-holder, $columns, $gutter);
19
21
 
@@ -31,7 +33,13 @@
31
33
  }
32
34
  @else {
33
35
  float: $dir;
34
- margin-#{$opp}: gutter-span($gutter, $columns);
36
+
37
+ @if $start-row {
38
+ margin-#{$dir}: 0%;
39
+ }
40
+ @else {
41
+ margin-#{$opp}: gutter-span($gutter, $columns);
42
+ }
35
43
  }
36
44
  }
37
45
 
@@ -51,6 +59,14 @@
51
59
  }
52
60
  @else {
53
61
  float: $dir;
62
+
63
+ @if $start-row {
64
+ margin-#{$dir}: 0%;
65
+ }
66
+ @else {
67
+ margin-#{$opp}: gutter-span($gutter, $columns);
68
+ }
69
+
54
70
  margin-#{$dir}: 0;
55
71
  margin-#{$opp}: gutter-span($gutter, $columns);
56
72
  }
@@ -90,4 +106,36 @@
90
106
  $gutter: (column-span($span, $location, $columns, $gutter) + gutter-span($gutter, $columns)) * -1;
91
107
 
92
108
  margin-left: $gutter;
109
+ }
110
+
111
+ //////////////////////////////
112
+ // Happy Syntax for Float
113
+ //
114
+ // Makes working with Float easier, as it allows you to walk the grid for symmetric grids and easy applying of 'last' and 'first', as well as automatically building the verbose grid-span mixin call
115
+ //////////////////////////////
116
+ @mixin float-span($span, $location: false, $columns: false, $gutter: false) {
117
+ $grid: find-grid($columns);
118
+ $gutter: find-gutter($gutter);
119
+ $row: false;
120
+
121
+ @if type-of($grid) == 'number' or length($grid) == 1 {
122
+ @if $location == 'last' or $location == 'omega' {
123
+ $location: length($grid) - $span + 1;
124
+ }
125
+ @else {
126
+ @if $location == 'first' or $location == 'alpha' {
127
+ $row: true;
128
+ }
129
+ $location: 1;
130
+ }
131
+
132
+ @include grid-span($span, $location, $grid, $gutter, 'float');
133
+
134
+ @if $row {
135
+ clear: both;
136
+ }
137
+ }
138
+ @else {
139
+ @warn 'Asymmetric Grids need a Location value as well as a span value in order to know where on the grid you are! Please include a location value!';
140
+ }
93
141
  }
@@ -1,10 +1,11 @@
1
1
  @mixin output-isolation($span, $location, $columns, $gutter, $options: false) {
2
2
 
3
- @if $options == false {
4
- $options: 'right';
5
- }
6
-
7
3
  $gutter: find-gutter($gutter);
4
+ $end-row: end-row($span, $location, $columns);
5
+ $start-row: start-row($location);
6
+
7
+ // @debug $options;
8
+
8
9
 
9
10
  @if $direction == 'ltr' or $direction == 'both' {
10
11
  // Set the CSS direction to ltr
@@ -14,10 +15,35 @@
14
15
  $opp: opposite-direction($dir);
15
16
 
16
17
  width: column-span($span, $location, $columns);
17
- margin-#{$dir}: column-span($location - 1, 1, $columns);
18
- margin-#{$opp}: -100%;
19
- float: $dir;
20
- clear: unquote($options);
18
+
19
+
20
+
21
+ // If we are at the last item in the row, we float it the opposite direction
22
+ @if ($end-row) {
23
+ float: $opp;
24
+ margin-#{$dir}: 0;
25
+ margin-#{$opp}: 0;
26
+ }
27
+ @else {
28
+ float: $dir;
29
+ margin-#{$opp}: -100%;
30
+
31
+ @if $start-row {
32
+ margin-#{$dir}: 0%;
33
+ }
34
+ @else {
35
+ margin-#{$dir}: column-span(($location - 1), 1, $columns) + gutter-span($gutter, $columns);
36
+ }
37
+
38
+ }
39
+
40
+ // If options are set, we clear to that option, otherwise no clear!
41
+ @if ($options) {
42
+ clear: unquote($options);
43
+ }
44
+ @else {
45
+ clear: none;
46
+ }
21
47
  }
22
48
 
23
49
  @if $direction == 'rtl' or $direction == 'both' {
@@ -28,10 +54,29 @@
28
54
  $opp: opposite-direction($dir);
29
55
 
30
56
  [dir="#{$cssdir}"] & {
31
- margin-#{$dir}: column-span($location - 1, 1, $columns) + gutter-span($gutter, $columns);
32
- margin-#{$opp}: -100%;
33
- float: $dir;
34
- clear: unquote($options);
57
+ // If we are at the last item in the row, we float it the opposite direction
58
+ @if ($end-row) {
59
+ float: $opp;
60
+ }
61
+ @else {
62
+ float: $dir;
63
+ margin-#{$opp}: -100%;
64
+
65
+ @if $start-row {
66
+ margin-#{$dir}: 0%;
67
+ }
68
+ @else {
69
+ margin-#{$dir}: column-span(($location - 1), 1, $columns) + gutter-span($gutter, $columns);
70
+ }
71
+ }
72
+
73
+ // If options are set, we clear to that option, otherwise no clear!
74
+ @if ($options) {
75
+ clear: unquote($options);
76
+ }
77
+ @else {
78
+ clear: none;
79
+ }
35
80
  }
36
81
  }
37
82
 
@@ -45,4 +90,16 @@
45
90
 
46
91
  @mixin pull-isolation($span, $location, $columns: false, $gutter: false) {
47
92
  @include pull-float($span, $location, $columns, $gutter);
93
+ }
94
+
95
+ //////////////////////////////
96
+ // Happy Syntax for Isolation
97
+ //
98
+ // Makes working with Isolation easier, as it moves Clear to a 1st class citizen of the mixin, and automatically builds the verbose grid-span mixin call
99
+ //////////////////////////////
100
+ @mixin isolation-span($span, $location, $clear: false, $columns: false, $gutter: false) {
101
+ $grid: find-grid($columns);
102
+ $gutter: find-gutter($gutter);
103
+
104
+ @include grid-span($span, $location, $grid, $gutter, 'isolation', $clear);
48
105
  }
@@ -120,67 +120,114 @@ $overlay-switch-position: left bottom !default;
120
120
  @mixin background-grid(
121
121
  $columns: false,
122
122
  $gutter: false,
123
- $color: rgba(Chocolate, .5)
123
+ $color: Chocolate
124
124
  ) {
125
125
 
126
126
  $background-length: length($grids);
127
127
 
128
- @if not ($columns) {
129
- @for $i from 1 through $background-length {
130
- @if $i == 1 {
131
- @include background-build($columns, $gutter, $color);
132
- }
133
- @else {
128
+ @if (not $columns) {
129
+ $grid: find-grid($columns);
130
+ @include background-build($grid, $gutter, $color);
131
+ @if ($grid != $grids) {
132
+ @for $i from 2 through $background-length {
134
133
  $mq: nth(nth($grids, $i), 2);
135
-
136
134
  $grid: nth(nth($grids, $i), 1);
135
+
137
136
  @include breakpoint($mq) {
138
137
  @include background-build($grid, $gutter, $color);
139
138
  }
140
139
  }
141
140
  }
142
141
  }
142
+ @else {
143
+ @include background-build($columns, $gutter, $color);
144
+ }
143
145
  }
144
146
 
145
147
  @mixin background-build($columns, $gutter, $color) {
146
148
  $columns: find-grid($columns);
147
149
  $gutter: find-gutter($gutter);
148
150
 
149
- $stops: background-gradient-stops($columns, $gutter, $color);
151
+ $widths: ();
152
+ $colors: ();
150
153
 
151
- @include background(
152
- linear-gradient(
153
- left, $stops
154
- )
155
- );
156
- }
154
+ $length: length($columns);
155
+ $symmetric: false;
156
+ @if type-of($columns) == 'number' or $length == 1 {
157
+ $symmetric: true;
158
+ $length: nth($columns, 1);
159
+ }
157
160
 
158
- //////////////////////////////
159
- // Get the stops of the gradient
160
- //////////////////////////////
161
- @function background-gradient-stops($columns, $gutter, $color) {
162
- $bkg: ();
163
- $count: column-count($columns);
164
161
 
165
- @for $i from 1 through column-count($columns) {
166
- $bkg: join($bkg, background-column-gradient($i, $columns, $gutter, $color), comma);
162
+ @for $i from 1 through $length {
163
+ $column-span: column-span($i, 1, $columns);
164
+ $gutter-span: $column-span + gutter-span($gutter, $columns);
165
+
166
+ @if $i != $columns {
167
+ $widths: append($widths, $column-span);
168
+ $colors: append($colors, rgba($color, .5));
169
+ $widths: append($widths, $gutter-span);
170
+ $colors: append($colors, rgba($color, .25));
171
+ }
172
+ @else {
173
+ $widths: append($widths, $column-span);
174
+ $colors: append($colors, rgba($color, .5));
175
+ }
167
176
  }
168
177
 
169
- @return $bkg;
178
+ @include background-gradient-generate($widths, $colors);
179
+
170
180
  }
171
181
 
172
182
  //////////////////////////////
173
183
  // Get the columns
174
184
  //////////////////////////////
175
- @function background-column-gradient($location, $columns, $gutter, $color) {
185
+ @mixin background-gradient-generate($widths, $colors, $direction: left) {
186
+ @if (length($widths) != length($colors)) and (length($widths) != length($colors) - 1) {
187
+ @warn 'You either need an equal number of widths and colors or one less width than color, in which case it is assumed that the last width goes to 100%. Please provide the correct amount of widths and colors.';
188
+ }
189
+ @else {
190
+ $stops: ();
191
+
192
+ @if length($widths) == (length($colors) - 1) {
193
+ $widths: append($widths, 100%);
194
+ }
195
+
196
+ $i: 1;
197
+
198
+ @each $width in $widths {
199
+ $width: nth($widths, $i);
200
+ $color: nth($colors, $i);
176
201
 
177
- @if $location == 1 {
178
- @return lighten($color, 5%) 0%, darken($color, 5%) column-span(1, 1, $columns), lighten($color, 30%) column-span(1, 1, $columns);
202
+ @if $i == 1 {
203
+ $stops: join($stops, build-gradient-piece($width, $color), comma);
204
+ }
205
+ @else {
206
+ $position: nth($widths, $i - 1);
207
+ $stops: join($stops, build-gradient-piece($width, $color, $position), comma);
208
+ }
209
+
210
+ $i: $i + 1;
211
+ }
212
+
213
+ // @debug $stops;
214
+
215
+
216
+
217
+ @include background-image(
218
+ linear-gradient($direction, $stops)
219
+ );
179
220
  }
180
- @if $location == column-count($columns) {
181
- @return lighten($color, 30%) column-span($location - 1, 1, $columns) + gutter-span($gutter, $columns), lighten($color, 5%) column-span($location - 1, 1, $columns) + gutter-span($gutter, $columns), darken($color, 5%) 100%;
221
+ }
222
+
223
+ @function build-gradient-piece($width, $color, $position: false) {
224
+ @if ($position == 'last') {
225
+ @return ($color $width);
182
226
  }
183
- @if $location > 1 {
184
- @return lighten($color, 30%) column-span($location - 1, 1, $columns) + gutter-span($gutter, $columns), lighten($color, 5%) column-span($location - 1, 1, $columns) + gutter-span($gutter, $columns), darken($color, 5%) column-span($location, 1, $columns), lighten($color, 30%) column-span($location, 1, $columns);
227
+ @else if ($position != false) {
228
+ @return $color $position, $color $width;
185
229
  }
186
- }
230
+ @else {
231
+ @return $color, $color $width;
232
+ }
233
+ }
@@ -12,4 +12,13 @@
12
12
  @return false;
13
13
  }
14
14
  }
15
+ }
16
+
17
+ @function start-row($location) {
18
+ @if $location == 1 {
19
+ @return true;
20
+ }
21
+ @else {
22
+ @return false;
23
+ }
15
24
  }
@@ -11,61 +11,70 @@
11
11
  @return $user-object;
12
12
  }
13
13
  @else if $length > 1 {
14
- $query-min: breakpoint-get-context('min-width');
15
- $query-max: breakpoint-get-context('max-width');
14
+ //////////////////////////////
15
+ // @TODO! REplace with Native Sass Fucntion when vailable!
16
+ // https://github.com/nex3/sass/pull/689
17
+ //////////////////////////////
18
+ @if (is-breakpoint-list($haystack) != false) {
19
+ $query-min: breakpoint-get-context('min-width');
20
+ $query-max: breakpoint-get-context('max-width');
16
21
 
17
- // If we've got a min-width or max-width
18
- @if $query-min or $query-max {
19
- // Reverse the grid so we can step through it
20
- $reverse-haystack: ();
21
- @for $i from 2 through $length {
22
- $reverse-haystack: append($reverse-haystack, nth($haystack, $i), comma);
23
- }
24
- $reverse-haystack: reverse($reverse-haystack);
25
- $rg-length: $length - 1;
22
+ // If we've got a min-width or max-width
23
+ @if $query-min or $query-max {
24
+ // Reverse the grid so we can step through it
25
+ $reverse-haystack: ();
26
+ @for $i from 2 through $length {
27
+ $reverse-haystack: append($reverse-haystack, nth($haystack, $i), comma);
28
+ }
29
+ $reverse-haystack: reverse($reverse-haystack);
30
+ $rg-length: $length - 1;
26
31
 
27
- // Grab the largest and smallest MQs
28
- $smallest: nth(nth($haystack, 2), 2);
29
- $largest: nth(nth($reverse-haystack, 1), 2);
30
- $context: $query-min;
32
+ // Grab the largest and smallest MQs
33
+ $smallest: nth(nth($haystack, 2), 2);
34
+ $largest: nth(nth($reverse-haystack, 1), 2);
35
+ $context: $query-min;
31
36
 
32
- @if not ($mobile-first) {
33
- $context: $query-max;
34
- }
37
+ @if not ($mobile-first) {
38
+ $context: $query-max;
39
+ }
35
40
 
36
41
 
37
- // If it's smallest than the smallest MQ, use the 1st grid
38
- @if $context < $smallest {
39
- @return nth($haystack, 1);
40
- }
41
- // If it's larger than or equal to the largest MQ, use the last grid
42
- @else if $context >= $largest {
43
- @return nth(nth($reverse-haystack, 1), 1);
44
- }
45
- // If it's in between the smallest and largest, go run a check.
46
- @else {
47
- // Loop through each MQ.
48
- @for $j from 1 through $rg-length {
49
- $query: nth(nth($reverse-haystack, $j), 2);
42
+ // If it's smallest than the smallest MQ, use the 1st grid
43
+ @if $context < $smallest {
44
+ @return nth($haystack, 1);
45
+ }
46
+ // If it's larger than or equal to the largest MQ, use the last grid
47
+ @else if $context >= $largest {
48
+ @return nth(nth($reverse-haystack, 1), 1);
49
+ }
50
+ // If it's in between the smallest and largest, go run a check.
51
+ @else {
52
+ // Loop through each MQ.
53
+ @for $j from 1 through $rg-length {
54
+ $query: nth(nth($reverse-haystack, $j), 2);
50
55
 
51
- // If the MQ is greather than or equal to the the MQ in question, use it! (mobile first)
52
- @if ($mobile-first) {
53
- @if $context >= $query {
54
- @return nth(nth($reverse-haystack, $j), 1);
56
+ // If the MQ is greather than or equal to the the MQ in question, use it! (mobile first)
57
+ @if ($mobile-first) {
58
+ @if $context >= $query {
59
+ @return nth(nth($reverse-haystack, $j), 1);
60
+ }
55
61
  }
56
- }
57
- // If the MQ is less than or equal to the the MQ in question, use it! (not mobile first)
58
- @else {
59
- @if $context <= $query {
60
- @return nth(nth($reverse-haystack, $j), 1);
62
+ // If the MQ is less than or equal to the the MQ in question, use it! (not mobile first)
63
+ @else {
64
+ @if $context <= $query {
65
+ @return nth(nth($reverse-haystack, $j), 1);
66
+ }
61
67
  }
62
68
  }
63
69
  }
64
70
  }
71
+ // All else fails, return the first grid
72
+ @else {
73
+ @return nth($haystack, 1);
74
+ }
65
75
  }
66
- // All else fails, return the first grid
67
76
  @else {
68
- @return nth($haystack, 1);
77
+ @return $haystack;
69
78
  }
70
79
  }
71
80
  // All else fails, return the first grid
@@ -7,26 +7,36 @@
7
7
  $columns: find-grid($columns);
8
8
  $gutter: find-gutter($gutter);
9
9
 
10
+ // @debug $columns;
11
+ // @debug $gutter;
12
+
10
13
  // Combine the columns and gutters
11
14
  $columns-and-gutters: column-sum($columns, $gutter);
12
15
 
16
+ // @debug $columns-and-gutters;
17
+
13
18
  // Equal width columns are easy! Deal with them!
14
19
  @if type-of($columns) == 'number' or length($columns) == 1 {
15
- $span-and-gutters: $span + (($span - 1) * nth($gutter, 1));
20
+ $span-and-gutters: $span + $gutter * ($span - 1);
16
21
  @return $span-and-gutters / $columns-and-gutters * 100%;
17
22
  }
18
23
  // Asymmetric lists are harder, so we're going to treat them as their own columns
19
24
  @else if type-of($columns) == 'list' or length($columns) > 1 {
20
- // Build a fake column set
21
- $sum: 0;
22
- $holder: ();
25
+ $span-and-gutters: 0;
23
26
 
24
- @for $i from $location to ($location + $span) {
25
- $holder: append($holder, nth(nth($columns, $i), 1), comma);
27
+ @if $location == 1 and $span >= 1 {
28
+ @for $i from 1 through $span {
29
+ $span-and-gutters: $span-and-gutters + nth($columns, $i) + $gutter;
30
+ }
31
+ }
32
+ @else {
33
+ $total: $location + $span - 1;
34
+ @for $i from $location through $total {
35
+ $span-and-gutters: $span-and-gutters + nth($columns, $i) + $gutter;
36
+ }
26
37
  }
38
+ $span-and-gutters: $span-and-gutters - $gutter;
27
39
 
28
- // Get sub-column sum
29
- $span-and-gutters: column-sum($holder, $gutter);
30
40
  @return $span-and-gutters / $columns-and-gutters * 100%;
31
41
  }
32
42
  @else {
@@ -0,0 +1,3 @@
1
+ @function grid-span($span, $location, $grid: false, $gutter: false) {
2
+ @return column-span($span, $location, $grid, $gutter) + gutter-span($gutter, $grid);
3
+ }
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 1
9
- version: 1.0.1
8
+ - 2
9
+ version: 1.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Scott Kellum
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-04-02 00:00:00 -04:00
18
+ date: 2013-04-03 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -99,6 +99,7 @@ files:
99
99
  - stylesheets/singularitygs/math/_columns.scss
100
100
  - stylesheets/singularitygs/math/_context.scss
101
101
  - stylesheets/singularitygs/math/_gutters.scss
102
+ - stylesheets/singularitygs/math/_span.scss
102
103
  - templates/box-sizing/behaviors/box-sizing/boxsizing.htc
103
104
  - templates/box-sizing/behaviors/box-sizing/boxsizing.php
104
105
  - templates/box-sizing/manifest.rb