singularitygs 0.0.16 → 0.0.17

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.16"
9
- DATE = "2012-10-28"
8
+ VERSION = "0.0.17"
9
+ DATE = "2012-11-05"
10
10
  end
@@ -15,10 +15,6 @@ $gutter: .25 !default;
15
15
  // Grid padding can be any type of unit
16
16
  $padding: 0 !default;
17
17
 
18
- // Grid structure
19
- // Only option is float at the moment
20
- $grid-structure: float !default;
21
-
22
18
  // Layout direction?
23
19
  // options are ltr, rtl, both
24
20
  $dir: ltr !default;
@@ -41,6 +37,12 @@ $container-to-ems: false !default;
41
37
  // Base Font Size
42
38
  $base-font-size: 1em !default;
43
39
 
40
+ // Structural templates for grid
41
+ $grouped-styles: false !default;
42
+ $output: 'isolation' !default;
43
+ @import "singularitygs/grid-structure/isolation";
44
+ @import "singularitygs/grid-structure/float";
45
+
44
46
  // Helpers return think like list sums and column counts
45
47
  @import "singularitygs/helpers";
46
48
 
@@ -56,9 +58,6 @@ $base-font-size: 1em !default;
56
58
  // Grid math combines column and gutter math
57
59
  @import "singularitygs/grid";
58
60
 
59
- // Structural templates for grid
60
- @import "singularitygs/grid-structure";
61
-
62
61
  // Mixins to write
63
62
  @import "singularitygs/mixins";
64
63
 
@@ -66,7 +65,4 @@ $base-font-size: 1em !default;
66
65
  @import "singularitygs/grid-test";
67
66
 
68
67
  // Mixins to write
69
- @import "singularitygs/background-grid";
70
-
71
- // Gridsets
72
- @import "singularitygs/gridsets";
68
+ @import "singularitygs/background-grid";
@@ -1,43 +1,3 @@
1
- // Calculate the total sum of a list (context)
2
- @function list-sum($list) {
3
- // zero out the initial sum
4
- $sum: 0;
5
- // loop through each value in the list adding it to $list-sum
6
- @for $i from 1 through length($list) {
7
- $sum: $sum + nth(nth($list, $i), 1);
8
- }
9
- @return nth($sum, 1);
10
- }
11
-
12
- // Find column count
13
- @function column-count($columns) {
14
- @if type-of($columns) == number {
15
- @return $columns;
16
- }
17
- @if type-of($columns) == list {
18
- @return length($columns);
19
- }
20
- }
21
-
22
- // Context of gutters
23
- @function gutter-context($gutter, $context) {
24
- @return $gutter * 100% / $context;
25
- }
26
-
27
- @function repeat($count, $repeat) {
28
- $list: $repeat;
29
- @for $i from 2 through $count {
30
- $list: join($repeat, $list);
31
- }
32
- @return $list;
33
- }
34
-
35
- // Reverses direction of a list
36
- @function reverse($list) {
37
- $length: length($list);
38
- $return: ();
39
- @for $i from 0 to $length {
40
- $return: append($return, nth($list, $length - $i), comma);
41
- }
42
- @return $return;
43
- }
1
+ @import "helpers/lists";
2
+ @import "helpers/grids";
3
+ @import "helpers/gridsets";
@@ -1,222 +1,7 @@
1
- // Converted old Grid Span into Grid Build
2
- // It a piece of cake to make a pretty grid, CAKE!
3
- @mixin grid-build($span, $location, $columns, $gutter, $padding) {
4
- @include box-sizing(border-box);
5
- *behavior: url('../behaviors/box-sizing/boxsizing.php');
6
- width: grid-span($span, $location, $columns, $gutter);
7
- @if $grid-structure == float {
8
- @include structure-float($span, $location, $columns, $gutter);
9
- }
10
- // add special left padding
11
- @if type-of($columns) == list {
12
- @if type-of(nth($columns, $location)) == list {
13
- padding-left: nth(nth($columns, $location), 2);
14
- }
15
- @else if $padding != 0 {
16
- padding-left: $padding;
17
- }
18
- // add special right padding
19
- @if type-of(nth($columns, $location + $span - 1)) == list {
20
- padding-right: nth(nth($columns, $location + $span - 1), 2);
21
- }
22
- @else if $padding != 0 {
23
- padding-right: $padding;
24
- }
25
- }
26
- @else if $padding != 0 {
27
- padding: 0 $padding;
28
- }
29
- // bump up the counter
30
- $grid-counter: $location + $span;
31
- @if $grid-counter > column-count($columns) {
32
- $grid-counter: 1;
33
- }
34
- }
35
-
36
- // This writes classes, IDs, or silent objects for you to extend or use in your HTML. They can be written to different breakpoints to extend or call into your HTML as needed.
37
- @mixin grid-objects($prefix: a, $columns: $columns, $gutter: $gutter, $padding: $padding, $selector: "%") {
38
- $grouped-styles: true;
39
- // counter keeps track of the starting position
40
- $count: 0;
41
- %#{$prefix}column {
42
- @if $dir == ltr or $dir == both {
43
- margin-right: -100%;
44
- float: left;
45
- }
46
- @if $dir == rtl {
47
- margin-left: -100%;
48
- float: right;
49
- }
50
- @if $dir == both {
51
- #{$rtl-selector} & {
52
- margin-left: -100%;
53
- float: right;
54
- }
55
- }
56
- float: left;
57
- @include grid-padding($padding);
58
- margin-right: $gutter;
59
- }
60
- // This function now labels object prefix+span.location
61
- @for $i from 1 through column-count($columns) {
62
- @for $n from 1 through (column-count($columns) - $count) {
63
- #{$selector}#{$prefix}#{$n}-#{$count + 1} {
64
- @extend %#{$prefix}column;
65
- @include grid-span($n, $count + 1, $columns, $gutter);
66
- }
67
- }
68
- $count: $count + 1;
69
- }
70
- }
71
-
72
- // Add padding to an object on the grid.
73
- @mixin grid-padding($padding) {
74
- @if $padding != 0 {
75
- padding: 0 $padding;
76
- @include box-sizing(border-box);
77
- *behavior: url('../behaviors/box-sizing/boxsizing.php');
78
- }
79
- }
80
-
81
- //////////////////////////////
82
- // Container Mixin
83
- //////////////////////////////
84
- @mixin container($max-width: $container, $bfs: $base-font-size) {
85
- $bfs-length: length($bfs);
86
- $bfs-counter: 1;
87
-
88
- @if length($containers) != 0 {
89
- $query: 'min-width';
90
- @if $grids-mobile-first == false {
91
- $query: 'max-width';
92
- }
93
-
94
- $total: length($containers);
95
-
96
- @if $total > 1 {
97
- @for $i from 2 through $total {
98
-
99
- @include breakpoint((nth(nth($containers, $i), 2) $query)) {
100
- $bfs-holder: bfs-finder($query);
101
- @if unit(nth(nth($containers, $i), 1)) != '%' and $container-to-ems == true {
102
- max-width: base-conversion(nth(nth($containers, $i), 1)) / base-conversion($bfs-holder) * 1em;;
103
- }
104
- @else {
105
- max-width: nth(nth($containers, $i), 1);
106
- }
107
- }
108
- }
109
- }
110
- @if unit(nth($containers, 1)) != '%' {
111
- max-width: breakpoint-to-base-em(nth($containers, 1), nth($bfs, 1));
112
- }
113
- @else {
114
- max-width: nth($containers, 1);
115
- }
116
- }
117
- @else {
118
- @if unit($max-width) != '%' and $container-to-ems == true {
119
- max-width: base-conversion($max-width) / base-conversion($bfs) * 1em;
120
- }
121
- @else {
122
- max-width: $max-width;
123
- }
124
- }
125
-
126
- //////////////////////////////
127
- // Center Container
128
- //////////////////////////////
129
- margin: 0 auto;
130
-
131
- //////////////////////////////
132
- // Overflow: Hidden
133
- //////////////////////////////
134
- overflow: hidden;
135
-
136
- //////////////////////////////
137
- // Border box and clearfix
138
- //////////////////////////////
139
- @include box-sizing(border-box);
140
- *behavior: url('../behaviors/box-sizing/boxsizing.php');
141
-
142
- &:before,
143
- &:after {
144
- content: "";
145
- display: table;
146
- }
147
-
148
- &:after {
149
- clear: both;
150
- }
151
-
152
- @if $legacy-support-for-ie6 or $legacy-support-for-ie7 {
153
- /* for IE 6/7 */
154
- *zoom: expression(this.runtimeStyle.zoom="1", this.appendChild(document.createElement("br")).style.cssText="clear:both;font:0/0 serif");
155
- }
156
- /* non-JS fallback */
157
- *zoom: 1;
158
- }
159
-
160
- //////////////////////////////
161
- // Base Font Size in HTML tag
162
- // NOT DONE YET!
163
- //////////////////////////////
164
- @mixin base-font-sizing($bfs: $base-font-size) {
165
- $bfs-length: length($base-font-size);
166
- $query: 'min-width';
167
- @if $grids-mobile-first == false {
168
- $query: 'max-width';
169
- }
170
-
171
- html {
172
- font-size: nth($bfs, 1);
173
-
174
- @if $bfs-length > 1 {
175
- @for $i from 2 through $bfs-length {
176
- @include breakpoint((nth(nth($bfs, $i), 2) $query)) {
177
- font-size: nth(nth($bfs, $i), 1);
178
- }
179
- }
180
- }
181
- }
182
- }
183
-
184
- ////////////////////////////////
185
- //// Find Base Font Size
186
- ////////////////////////////////
187
- @function bfs-finder($query) {
188
- $context: breakpoint-get-context($query);
189
- $reverse: reverse($base-font-size);
190
-
191
- @if $grids-mobile-first == false {
192
- $query: 'max-width';
193
- }
194
-
195
- @if $query == "min-width" and $context != false {
196
- @each $size in $reverse {
197
- @if length($size) == 2 {
198
- @if nth($size, 2) < $context {
199
- @return nth($size, 1);
200
- }
201
- }
202
- @else {
203
- @return nth($base-font-size, 1);
204
- }
205
- }
206
- }
207
- @else if $query == "max-width" and $context != false {
208
- @each $size in $reverse {
209
- @if length($size) == 2 {
210
- @if nth($size, 2) > $context {
211
- @return nth($size, 1);
212
- }
213
- }
214
- @else {
215
- @return nth($base-font-size, 1);
216
- }
217
- }
218
- }
219
- @else {
220
- @return nth($base-font-size, 1);
221
- }
222
- }
1
+ @import 'mixins/grid-span';
2
+ @import 'mixins/base-font-size';
3
+ @import 'mixins/grid-build';
4
+ @import 'mixins/container';
5
+ @import 'mixins/grid-objects';
6
+ @import 'mixins/grid-padding';
7
+ @import "mixins/push-pull";
@@ -0,0 +1,94 @@
1
+ @mixin float-clear($dir) {
2
+ @if $dir == 'left' {
3
+ clear: right;
4
+ }
5
+ @else if $dir == 'right' {
6
+ clear: left;
7
+ }
8
+ @else if $dir == 'both' {
9
+ clear: both;
10
+ }
11
+
12
+ @include clearfix;
13
+ }
14
+
15
+ @mixin float-common($columns: $columns, $gutter: $gutter, $padding: $padding, $grouped-styles: $grouped-styles) {
16
+ @include box-sizing(border-box);
17
+ *behavior: url("../behaviors/box-sizing/boxsizing.php");
18
+ overflow: hidden;
19
+ *zoom: 1;
20
+
21
+ @if $grouped-styles and $padding != 0 {
22
+ padding-left: $padding;
23
+ padding-right: $padding;
24
+ }
25
+ @if $grouped-styles == false and $padding != 0 {
26
+
27
+ }
28
+ }
29
+
30
+
31
+
32
+ @mixin float-section($span, $location: $grid-counter, $columns: $columns, $gutter: $gutter, $padding: $padding, $grouped-styles: $grouped-styles) {
33
+ width: grid-span($span, $location, $columns, $gutter);
34
+ // add special left padding
35
+ @include grid-location($span, $location, $columns);
36
+
37
+ @if $dir == ltr or $dir == both {
38
+ @if $grid-location == 'middle' or $grid-location == 'first'{
39
+ float: left;
40
+ margin-right: gutter-span($gutter, $columns);
41
+ }
42
+ @else if $grid-location == 'last' {
43
+ float: right;
44
+ }
45
+ @include float-clear('left');
46
+ }
47
+ @if $dir == rtl {
48
+ @if $grid-location == 'middle' or $grid-location == 'first' {
49
+ float: right;
50
+ margin-left: gutter-span($gutter, $columns);
51
+ }
52
+ @else if $grid-location == 'last' {
53
+ float: left;
54
+ }
55
+ @include float-clear('right');
56
+ }
57
+ @if $dir == both {
58
+ #{$rtl-selector} & {
59
+ @if $grid-location == 'middle' or $grid-location == 'first' {
60
+ float: right;
61
+ margin-left: gutter-span($gutter, $columns);
62
+ }
63
+ @else if $grid-location == 'last' {
64
+ float: left;
65
+ }
66
+ @include float-clear('right');
67
+ }
68
+ }
69
+
70
+ // Padding
71
+ @if type-of($columns) == list {
72
+ @if type-of(nth($columns, $location)) == list {
73
+ padding-left: nth(nth($columns, $location), 2);
74
+ }
75
+ @else if $padding != 0 {
76
+ padding-left: $padding;
77
+ }
78
+ // add special right padding
79
+ @if type-of(nth($columns, $location + $span - 1)) == list {
80
+ padding-right: nth(nth($columns, $location + $span - 1), 2);
81
+ }
82
+ @else if $padding != 0 {
83
+ padding-right: $padding;
84
+ }
85
+ }
86
+ }
87
+
88
+ @mixin float-structure($span, $location, $columns, $gutter, $padding) {
89
+ // common components
90
+ @include float-common($columns, $gutter);
91
+
92
+ // specific styles
93
+ @include float-section($span, $location, $columns, $gutter);
94
+ }
@@ -0,0 +1,145 @@
1
+ @mixin isolation-clear($dir) {
2
+ @if $dir == 'left' {
3
+ clear: right;
4
+ @if $grouped-styles {
5
+ margin-right: -100%;
6
+ float: left;
7
+ }
8
+ }
9
+ @else if $dir == 'right' {
10
+ clear: left;
11
+ @if $grouped-styles {
12
+ margin-left: -100%;
13
+ float: right;
14
+ }
15
+ }
16
+ @else if $dir == 'both' {
17
+ clear: both;
18
+ @if $grouped-styles {
19
+ margin-right: -100%;
20
+ float: left;
21
+ }
22
+ }
23
+
24
+ @include clearfix;
25
+ }
26
+
27
+ @mixin isolation-common($columns: $columns, $gutter: $gutter, $padding: $padding, $grouped-styles: $grouped-styles) {
28
+ @include box-sizing(border-box);
29
+ *behavior: url("../behaviors/box-sizing/boxsizing.php");
30
+ overflow: hidden;
31
+ *zoom: 1;
32
+
33
+ @if $grouped-styles and $padding != 0 {
34
+ padding-left: $padding;
35
+ padding-right: $padding;
36
+ }
37
+ @if $grouped-styles == false and $padding != 0 {
38
+
39
+ }
40
+ }
41
+
42
+
43
+
44
+ @mixin isolation-section($span, $location: $grid-counter, $columns: $columns, $gutter: $gutter, $padding: $padding, $grouped-styles: $grouped-styles) {
45
+ width: grid-span($span, $location, $columns, $gutter);
46
+ // add special left padding
47
+
48
+ @include grid-location($span, $location, $columns);
49
+
50
+ @if $dir == ltr or $dir == both {
51
+ @if $grid-location == 'middle' {
52
+ @if $grouped-styles == false {
53
+ margin-right: -100%;
54
+ float: left;
55
+ @include isolation-clear('left');
56
+ }
57
+ }
58
+ @else if $grid-location == 'first' {
59
+ @if $grouped-styles == false {
60
+ margin-right: -100%;
61
+ float: left;
62
+ @include isolation-clear('left');
63
+ }
64
+ margin-left: 0;
65
+ }
66
+ @else if $grid-location == 'last' {
67
+ float: right;
68
+ margin-right: 0;
69
+ @include isolation-clear('left');
70
+ }
71
+ }
72
+ @if $dir == rtl {
73
+ @if $grid-location == 'middle' {
74
+ @if $grouped-styles == false {
75
+ margin-left: -100%;
76
+ float: right;
77
+ @include isolation-clear('right');
78
+ }
79
+ }
80
+ @else if grid-location == 'first' {
81
+ @if $grouped-styles {
82
+ margin-left: -100%;
83
+ float: right;
84
+ @include isolation-clear('right');
85
+ }
86
+ margin-right: 0;
87
+ }
88
+ @else if $grid-location == 'last' {
89
+ float: left;
90
+ margin-left: 0;
91
+ @include isolation-clear('right');
92
+ }
93
+ }
94
+ @if $dir == both {
95
+ #{$rtl-selector} & {
96
+ @if $grid-location == 'middle' {
97
+ @if $grouped-styles {
98
+ margin-left: -100%;
99
+ float: right;
100
+ @include isolation-clear('right');
101
+ }
102
+ }
103
+ @if $grid-location == 'first' {
104
+ @if $grouped-styles {
105
+ margin-left: -100%;
106
+ float: right;
107
+ @include isolation-clear('right');
108
+ }
109
+ margin-right: 0;
110
+ }
111
+ @if $grid-location == 'last' {
112
+ float: left;
113
+ margin-left: 0;
114
+ @include isolation-clear('right');
115
+ }
116
+ }
117
+ }
118
+
119
+ @include push($location - 1, 1, $columns, $gutter);
120
+
121
+ // Padding
122
+ @if type-of($columns) == list {
123
+ @if type-of(nth($columns, $location)) == list {
124
+ padding-left: nth(nth($columns, $location), 2);
125
+ }
126
+ @else if $padding != 0 {
127
+ padding-left: $padding;
128
+ }
129
+ // add special right padding
130
+ @if type-of(nth($columns, $location + $span - 1)) == list {
131
+ padding-right: nth(nth($columns, $location + $span - 1), 2);
132
+ }
133
+ @else if $padding != 0 {
134
+ padding-right: $padding;
135
+ }
136
+ }
137
+ }
138
+
139
+ @mixin isolation-structure($span, $location, $columns, $gutter, $padding) {
140
+ // common components
141
+ @include isolation-common($columns, $gutter);
142
+
143
+ // specific styles
144
+ @include isolation-section($span, $location, $columns, $gutter);
145
+ }
@@ -0,0 +1,34 @@
1
+ // Find column count
2
+ @function column-count($columns) {
3
+ @if type-of($columns) == number {
4
+ @return $columns;
5
+ }
6
+ @if type-of($columns) == list {
7
+ @return length($columns);
8
+ }
9
+ }
10
+
11
+ // Context of gutters
12
+ @function gutter-context($gutter, $context) {
13
+ @return $gutter * 100% / $context;
14
+ }
15
+
16
+ // First or last column?
17
+ $grid-location: '';
18
+
19
+ @mixin grid-location($span, $location, $columns) {
20
+ $grid-location: '';
21
+
22
+ @if ($span + $location) > column-count($columns) {
23
+ $grid-location: 'last';
24
+ }
25
+ @else if $location == 1 {
26
+ $grid-location: 'first';
27
+ }
28
+ @else if $location == column-count($columns) {
29
+ $grid-location: 'last';
30
+ }
31
+ @else {
32
+ $grid-location: 'middle';
33
+ }
34
+ }