singularitygs 0.0.15.1 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
data/lib/singularitygs.rb CHANGED
@@ -5,6 +5,6 @@ require 'breakpoint'
5
5
  Compass::Frameworks.register("singularitygs", :path => "#{File.dirname(__FILE__)}/..")
6
6
 
7
7
  module SingularityGS
8
- VERSION = "0.0.15.1"
9
- DATE = "2012-10-10"
8
+ VERSION = "0.0.16"
9
+ DATE = "2012-10-28"
10
10
  end
@@ -3,6 +3,9 @@
3
3
  @import "modular-scale";
4
4
  @import "breakpoint";
5
5
 
6
+ // Singularity debug output
7
+ $singularity-debug: false !default;
8
+
6
9
  // Can be a number or a list of non-uniform column widths
7
10
  $columns: 12 !default;
8
11
 
@@ -1,19 +1,14 @@
1
- // calculate the width of individual columns
2
- //@function list-column-width($location, $columns) {
3
- // // send a warning if this is used when $columns is not a list
4
- // @if type-of($columns) != list {
5
- // @warn "The column-list-sum function requires the variable $columns to be a list.";
6
- // }
7
- // @else {
8
- // // divide the column from its context
9
- // @return nth(nth($columns, $location), 1) / list-sum($columns);
10
- // }
11
- //}
12
-
13
1
  // Calculate the width spanning multiple columns
14
- @function column-span($span, $location: 1, $columns: $columns) {
15
- $columns-and-gutters: column-sum($columns, $gutter);
2
+ @function column-span($span, $location: 1, $columns: $columns, $gutter: $gutter) {
3
+ // if the gutter is a percent, convert it to a ratio
16
4
 
5
+ @if unit($gutter) == '%' {
6
+ $gutter: percentage-gutter-conversion($gutter, $columns);
7
+ }
8
+
9
+ // gutters are a type of column
10
+ $columns-and-gutters: column-sum($columns, $gutter);
11
+
17
12
  // Equal width columns
18
13
  @if type-of($columns) == number {
19
14
  $span-and-gutter: $span + (($span - 1) * $gutter);
@@ -28,14 +23,20 @@
28
23
  @for $i from $location to $location + $span {
29
24
  $holder: append($holder, nth(nth($columns, $i), 1), comma);
30
25
  }
31
-
26
+
32
27
  @return column-sum($holder, $gutter) / $columns-and-gutters * 100%;
33
28
  }
34
-
29
+
35
30
  @return 10%;
36
31
  }
37
32
 
38
33
  @function column-sum($columns: $columns, $gutter: $gutter) {
34
+
35
+ // if the gutter is a percent, convert it to a ratio
36
+ @if unit($gutter) == percentage {
37
+ $gutter: percentage-gutter-conversion($gutter, $columns);
38
+ }
39
+
39
40
  @if type-of($columns) == 'number' {
40
41
  @return $columns + ((column-count($columns) - 1) * $gutter);
41
42
  }
@@ -1,2 +1,3 @@
1
1
  @import "grid-plugins/compound";
2
+ @import "grid-plugins/ratio-spiral";
2
3
  @import "grid-plugins/ratio";
@@ -1,4 +1,3 @@
1
1
  @import "grid-structure/structure-display-table";
2
- //@import "grid-structure/structure-clear";
3
2
  @import "grid-structure/structure-float";
4
3
  @import "grid-structure/structure-grid-layout";
@@ -1,3 +1,3 @@
1
1
  @function grid-span($span, $location: 1, $columns: $columns, $gutter: $gutter) {
2
- @return column-span($span, $location, $columns);
2
+ @return column-span($span, $location, $columns, $gutter);
3
3
  }
@@ -1,10 +1,44 @@
1
+ // percentage conversion
2
+ @function percentage-gutter-conversion($percent-gutter, $columns) {
3
+
4
+ // find the resolution of the grids
5
+ $resolution: 0;
6
+ @if length($columns) == 1 {
7
+ $resolution: $columns;
8
+ }
9
+ @else {
10
+ @each $column in $columns {
11
+ $resolution: $resolution + $column;
12
+ }
13
+ }
14
+
15
+ // divide the percentage gutter by 100% to get the offset
16
+ // then multiply be resolution for the full conversion
17
+ $new-gutter: ($percent-gutter / 100%) * $resolution;
18
+
19
+ @return $new-gutter;
20
+ }
21
+
22
+
1
23
  // Gutters to be removed from columns
2
24
  @function gutter-offset($gutter, $columns) {
25
+
26
+ // if the gutter is a percent, convert it to a ratio
27
+ @if unit($gutter) == percentage {
28
+ $gutter: percentage-gutter-conversion($gutter, $columns);
29
+ }
30
+
3
31
  $gutter-sum: $gutter * (column-count($columns) - 1);
4
32
  @return $gutter-sum / column-count($columns);
5
33
  }
6
34
 
7
35
  @function gutter-span($gutter, $columns) {
36
+
37
+ // if the gutter is a percent, convert it to a ratio
38
+ @if unit($gutter) == percentage {
39
+ $gutter: percentage-gutter-conversion($gutter, $columns);
40
+ }
41
+
8
42
  $columns-and-gutters: column-sum($columns, $gutter);
9
43
 
10
44
  @return $gutter / $columns-and-gutters * 100%;
@@ -57,11 +57,12 @@
57
57
  @include grid-padding($padding);
58
58
  margin-right: $gutter;
59
59
  }
60
+ // This function now labels object prefix+span.location
60
61
  @for $i from 1 through column-count($columns) {
61
- @for $n from $count + 1 through column-count($columns) {
62
- #{$selector}#{$prefix}#{$count}-#{$n} {
62
+ @for $n from 1 through (column-count($columns) - $count) {
63
+ #{$selector}#{$prefix}#{$n}-#{$count + 1} {
63
64
  @extend %#{$prefix}column;
64
- @include grid-span($n - $count, $count + 1, $columns, $gutter);
65
+ @include grid-span($n, $count + 1, $columns, $gutter);
65
66
  }
66
67
  }
67
68
  $count: $count + 1;
@@ -83,18 +84,18 @@
83
84
  @mixin container($max-width: $container, $bfs: $base-font-size) {
84
85
  $bfs-length: length($bfs);
85
86
  $bfs-counter: 1;
86
-
87
+
87
88
  @if length($containers) != 0 {
88
89
  $query: 'min-width';
89
90
  @if $grids-mobile-first == false {
90
91
  $query: 'max-width';
91
92
  }
92
-
93
+
93
94
  $total: length($containers);
94
-
95
+
95
96
  @if $total > 1 {
96
97
  @for $i from 2 through $total {
97
-
98
+
98
99
  @include breakpoint((nth(nth($containers, $i), 2) $query)) {
99
100
  $bfs-holder: bfs-finder($query);
100
101
  @if unit(nth(nth($containers, $i), 1)) != '%' and $container-to-ems == true {
@@ -121,28 +122,33 @@
121
122
  max-width: $max-width;
122
123
  }
123
124
  }
124
-
125
+
125
126
  //////////////////////////////
126
127
  // Center Container
127
128
  //////////////////////////////
128
129
  margin: 0 auto;
129
130
 
131
+ //////////////////////////////
132
+ // Overflow: Hidden
133
+ //////////////////////////////
134
+ overflow: hidden;
135
+
130
136
  //////////////////////////////
131
137
  // Border box and clearfix
132
138
  //////////////////////////////
133
139
  @include box-sizing(border-box);
134
140
  *behavior: url('../behaviors/box-sizing/boxsizing.php');
135
-
141
+
136
142
  &:before,
137
143
  &:after {
138
144
  content: "";
139
145
  display: table;
140
146
  }
141
-
147
+
142
148
  &:after {
143
149
  clear: both;
144
150
  }
145
-
151
+
146
152
  @if $legacy-support-for-ie6 or $legacy-support-for-ie7 {
147
153
  /* for IE 6/7 */
148
154
  *zoom: expression(this.runtimeStyle.zoom="1", this.appendChild(document.createElement("br")).style.cssText="clear:both;font:0/0 serif");
@@ -161,10 +167,10 @@
161
167
  @if $grids-mobile-first == false {
162
168
  $query: 'max-width';
163
169
  }
164
-
170
+
165
171
  html {
166
172
  font-size: nth($bfs, 1);
167
-
173
+
168
174
  @if $bfs-length > 1 {
169
175
  @for $i from 2 through $bfs-length {
170
176
  @include breakpoint((nth(nth($bfs, $i), 2) $query)) {
@@ -181,11 +187,11 @@
181
187
  @function bfs-finder($query) {
182
188
  $context: breakpoint-get-context($query);
183
189
  $reverse: reverse($base-font-size);
184
-
190
+
185
191
  @if $grids-mobile-first == false {
186
192
  $query: 'max-width';
187
193
  }
188
-
194
+
189
195
  @if $query == "min-width" and $context != false {
190
196
  @each $size in $reverse {
191
197
  @if length($size) == 2 {
@@ -1,46 +1,49 @@
1
- @function compound($c1: 1, $c2: 1, $c3: 1, $c4: 1, $c5: 1, $c6: 1) {
2
- $common-multiple: $c1 * $c2 * $c3 * $c4 * $c5 * $c6;
1
+ // 16 arguments can be passed into this function
2
+ // a max of 16 comma seperated grids
3
+ @function compound($cg1: 1, $cg2: 1, $cg3: 1, $cg4: 1, $cg5: 1, $cg6: 1, $cg7: 1, $cg8: 1, $cg9: 1, $cg10: 1, $cg11: 1, $cg12: 1, $cg13: 1, $cg14: 1, $cg15: 1, $cg16: 1) {
4
+
5
+ // merge arguments into a single list.
6
+ $compound-grids: $cg1, $cg2, $cg3, $cg4, $cg5, $cg6, $cg7, $cg8, $cg9, $cg10, $cg11, $cg12, $cg13, $cg14, $cg15, $cg16;
7
+
8
+ // Find the base resolution of grid
9
+ $resolution: 1;
10
+ @each $item in $compound-grids {
11
+ $resolution: $resolution * $item;
12
+ }
13
+
3
14
  $compound-grid: ();
4
15
  $compound-counter: 1;
5
- @for $i from 1 through $common-multiple {
16
+ // cycle through each step in grid resolution
17
+ @for $i from 1 through $resolution {
18
+
19
+ // dont add a column by default
6
20
  $add-col: false;
7
- @if $c1 != 1 {
8
- @if $i / $c1 == round($i / $c1) {
9
- $add-col: true;
10
- }
11
- }
12
- @if $c2 != 1 {
13
- @if $i / $c2 == round($i / $c2) {
14
- $add-col: true;
15
- }
16
- }
17
- @if $c3 != 1 {
18
- @if $i / $c3 == round($i / $c3) {
19
- $add-col: true;
20
- }
21
- }
22
- @if $c4 != 1 {
23
- @if $i / $c4 == round($i / $c4) {
24
- $add-col: true;
25
- }
26
- }
27
- @if $c5 != 1 {
28
- @if $i / $c5 == round($i / $c5) {
29
- $add-col: true;
30
- }
31
- }
32
- @if $c6 != 1 {
33
- @if $i / $c6 == round($i / $c6) {
21
+
22
+ // cycle through all grids to see if any grids match
23
+ @each $grid in $compound-grids {
24
+
25
+ // if the grid divides evenly into the resolution, add a column
26
+ // divide the resolution by number of columns to get the column resolution
27
+ @if $i / ($resolution / $grid) == round($i / ($resolution / $grid)) {
34
28
  $add-col: true;
35
29
  }
36
30
  }
31
+
32
+ // add the counter value to the compound grid list, reset counter
33
+ // this marks where one column ends and a new one begins
37
34
  @if $add-col {
38
35
  $compound-grid: join($compound-grid, $compound-counter, comma);
39
36
  $compound-counter: 1;
40
37
  }
38
+ // if no column is added, bump up counter
41
39
  @else {
42
40
  $compound-counter: $compound-counter + 1;
43
41
  }
44
42
  }
43
+
44
+ @if $singularity-debug {
45
+ @debug "Grid compounded to #{length($compound-grid)} columns";
46
+ }
47
+
45
48
  @return $compound-grid;
46
- }
49
+ }
@@ -0,0 +1,42 @@
1
+ // centralize spiral steps.
2
+ @function ratio-spiral-i($i) {
3
+ @return (($i * 2) + 1);
4
+ }
5
+
6
+ @function ratio-spiral($depth: 5, $ratio: golden(), $invert: false) {
7
+
8
+ // write the middle most column, a little out of step from the other columns.
9
+ $list: ms(ratio-spiral-i(-$depth) + 1, 100, $ratio);
10
+
11
+ // flip the direction the order columns are written in.
12
+ @if $invert == false {
13
+ @for $i from -($depth - 1) to 0 {
14
+ // if the number is even
15
+ @if $i/2 == round($i/2) {
16
+ // append after the list
17
+ $list: append($list, ms(ratio-spiral-i($i), 100, $ratio));
18
+ }
19
+ @else {
20
+ // append before the list
21
+ $list: append(ms(ratio-spiral-i($i), 100, $ratio), $list);
22
+ }
23
+ }
24
+ }
25
+
26
+ @else {
27
+ @for $i from -($depth - 1) to 0 {
28
+ @if $i/2 == round($i/2) {
29
+ $list: append(ms(ratio-spiral-i($i), 100, $ratio), $list);
30
+ }
31
+ @else {
32
+ $list: append($list, ms(ratio-spiral-i($i), 100, $ratio));
33
+ }
34
+ }
35
+ }
36
+
37
+ @if $singularity-debug {
38
+ @debug "Grid compounded to #{length($list)} columns";
39
+ }
40
+
41
+ @return $list;
42
+ }
@@ -16,5 +16,9 @@
16
16
  $return: reverse($return);
17
17
  }
18
18
 
19
+ @if $singularity-debug {
20
+ @debug "Grid compounded to #{length($return)} columns";
21
+ }
22
+
19
23
  @return $return;
20
24
  }
metadata CHANGED
@@ -5,9 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 15
9
- - 1
10
- version: 0.0.15.1
8
+ - 16
9
+ version: 0.0.16
11
10
  platform: ruby
12
11
  authors:
13
12
  - Scott Kellum
@@ -16,7 +15,7 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2012-10-10 00:00:00 -04:00
18
+ date: 2012-10-28 00:00:00 -04:00
20
19
  default_executable:
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
@@ -99,8 +98,8 @@ files:
99
98
  - stylesheets/singularitygs/_helpers.scss
100
99
  - stylesheets/singularitygs/_mixins.scss
101
100
  - stylesheets/singularitygs/grid-plugins/_compound.scss
101
+ - stylesheets/singularitygs/grid-plugins/_ratio-spiral.scss
102
102
  - stylesheets/singularitygs/grid-plugins/_ratio.scss
103
- - stylesheets/singularitygs/grid-structure/_structure-clear.scss
104
103
  - stylesheets/singularitygs/grid-structure/_structure-display-table.scss
105
104
  - stylesheets/singularitygs/grid-structure/_structure-float.scss
106
105
  - stylesheets/singularitygs/grid-structure/_structure-grid-layout.scss
@@ -1,32 +0,0 @@
1
- $legacy-support-for-ie6: true !default;
2
- $legacy-support-for-ie7: true !default;
3
-
4
- @mixin grid-clear($clear-dir) {
5
- @if $clear-dir == 'left' {
6
- clear: right;
7
- }
8
- @else if $clear-dir == 'right' {
9
- clear: left;
10
- }
11
- @else if $clear-dir == 'both' {
12
- clear: both;
13
- }
14
-
15
-
16
- &:before,
17
- &:after {
18
- content: "";
19
- display: table;
20
- }
21
-
22
- &:after {
23
- clear: both;
24
- }
25
-
26
- @if $legacy-support-for-ie6 or $legacy-support-for-ie7 {
27
- /* for IE 6/7 */
28
- *zoom: expression(this.runtimeStyle.zoom="1", this.appendChild(document.createElement("br")).style.cssText="clear:both;font:0/0 serif");
29
- }
30
- /* non-JS fallback */
31
- *zoom: 1;
32
- }