neat 0.4.2 → 1.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -11,4 +11,5 @@ images/
11
11
  css/
12
12
  _config.yml
13
13
  index.html
14
-
14
+ pkg
15
+ Gemfile.lock
data/README.md CHANGED
@@ -13,24 +13,18 @@ Requirements:
13
13
  - Sass 3.2+
14
14
  - Bourbon 2.1+
15
15
 
16
+ Put the `/neat` folder in your Sass directory and import it right below Bourbon in your stylesheets:
16
17
 
17
- Gemfile contents:
18
-
19
- gem 'bourbon'
20
- gem 'neat'
21
-
22
- After running `bundle install` you will be able to use bourbon and neat together. Within your application.css.scss file place the following:
23
-
24
- @import "bourbon";
25
- @import "neat";
18
+ @import "bourbon/bourbon";
19
+ @import "neat/neat";
26
20
 
27
21
 
28
22
  Using the grid
29
23
  ===
30
- The default grid uses 12 columns (a setting that can be easily overridden as detailed further down).
24
+ The default grid uses 12 columns, a setting that can be easily overridden as detailed [further down](https://github.com/thoughtbot/neat#changing-the-defaults).
31
25
 
32
26
  ### Containers
33
- Include the ```outer-container``` mixin in the topmost container (to which the ```max-width``` setting will be applied):
27
+ Include the `outer-container` mixin in the topmost container (to which the `max-width` setting will be applied):
34
28
 
35
29
  div.container {
36
30
  @include outer-container;
@@ -40,13 +34,13 @@ Include the ```outer-container``` mixin in the topmost container (to which the `
40
34
  You can include this mixin in more than one element in the same page.
41
35
 
42
36
  ### Columns
43
- Use the ```span-columns``` mixin to specify the number of columns an element should span:
37
+ Use the `span-columns` mixin to specify the number of columns an element should span:
44
38
 
45
39
  @include span-columns($span: $columns of $container-columns, $display: block)
46
40
 
47
- * ```columns``` is the number of columns you wish this element to span.
48
- * ```container-columns``` (optional) is the number of columns the container spans, defaults to the total number of columns in the grid.
49
- * ```display``` (optional) changes the display type of the grid. Use ```block```—the default—for floated layout, ```table``` for table-cell layout, and ```inline-block``` for an inline block layout.
41
+ * `columns` is the number of columns you wish this element to span.
42
+ * `container-columns` (optional) is the number of columns the container spans, defaults to the total number of columns in the grid.
43
+ * `display` (optional) changes the display type of the grid. Use `block`—the default—for floated layout, `table` for table-cell layout, and `inline-block` for an inline block layout.
50
44
 
51
45
  eg. Element that spans across 6 columns (out of the default 12):
52
46
 
@@ -69,7 +63,7 @@ If the element's parent isn't the top-most container, you need to add the number
69
63
  }
70
64
  }
71
65
 
72
- To use a table-cell layout, add ```table``` as the ```display``` argument:
66
+ To use a table-cell layout, add `table` as the `display` argument:
73
67
 
74
68
  @include span-columns(6 of 8, table)
75
69
 
@@ -85,44 +79,44 @@ The following syntaxes would also work:
85
79
 
86
80
 
87
81
  ### Rows
88
- In order to clear floated or table-cell columns, use the ```row``` mixin:
82
+ In order to clear floated or table-cell columns, use the `row` mixin:
89
83
 
90
84
  @include row($display);
91
85
 
92
- * ```display``` takes either ```block```—the default—or ```table```.
86
+ * `display` takes either `block`—the default—or `table`.
93
87
 
94
88
 
95
89
  ### Shifting columns
96
90
 
97
91
 
98
- To move an element to the left or right by a number of columns, use the ```shift``` mixin:
92
+ To move an element to the left or right by a number of columns, use the `shift` mixin:
99
93
 
100
94
  @include shift(2); // Move 2 columns to the right
101
95
  @include shift(-3); // Move 3 columns to the left
102
96
 
103
- Please note that the ```shift()``` mixin is incompatible with display ```table```.
97
+ Please note that the `shift()` mixin is incompatible with display `table`.
104
98
 
105
99
 
106
100
  ### Padding columns
107
101
 
108
- To add padding around the entire column use ```pad()```. By default it adds the same value as the grid's gutter but can take any unit value.
102
+ To add padding around the entire column use `pad()`. By default it adds the same value as the grid's gutter but can take any unit value.
109
103
 
110
104
  @include pad; // Adds a padding equivalent to the grid's gutter
111
- @extend pad(20px); // Adds a padding of 20px
105
+ @include pad(20px); // Adds a padding of 20px
112
106
 
113
- The ```pad()``` mixin works particularly well with ```span-columns(x, y, table)``` by adding the necessary padding without breaking your table-based grid layout.
107
+ The `pad()` mixin works particularly well with `span-columns(x, table)` by adding the necessary padding without breaking your table-based grid layout.
114
108
 
115
109
  ### Removing gutter
116
110
 
117
- Neat automatically removes the last columns's gutter. However, if you are queueing more than one row of columns within the same parent element, you need to specify which columns are considered last in their row to preserve the layout. Use the ```omega``` mixin to achieve this:
111
+ Neat automatically removes the last columns's gutter. However, if you are queueing more than one row of columns within the same parent element, you need to specify which columns are considered last in their row to preserve the layout. Use the `omega` mixin to achieve this:
118
112
 
119
113
  @include omega; // Removes right gutter
120
114
 
121
- You can also use ```nth-omega``` to remove the gutter of a specific column or set of columns:
115
+ You can also use `nth-omega` to remove the gutter of a specific column or set of columns:
122
116
 
123
117
  @include nth-omega(nth-child);
124
118
 
125
- * ```nth-child``` takes any valid :nth-child value. See [https://developer.mozilla.org/en-US/docs/CSS/:nth-child](Mozilla's :nth-child documentation)
119
+ * `nth-child` takes any valid :nth-child value. See [https://developer.mozilla.org/en-US/docs/CSS/:nth-child](Mozilla's :nth-child documentation)
126
120
 
127
121
  eg. Remove every 3rd gutter using:
128
122
 
@@ -136,12 +130,12 @@ This makes sure that the child fills 100% of its parent:
136
130
 
137
131
  ### Breakpoints
138
132
 
139
- The ```breakpoint()``` mixin allows you to use media-queries to modify both the grid and the layout. It takes two arguments:
133
+ The `breakpoint()` mixin allows you to use media-queries to modify both the grid and the layout. It takes two arguments:
140
134
 
141
135
  @include breakpoint($query:$feature $value, $total-columns: $grid-columns)
142
136
 
143
- * ```query``` contains the media feature (min-width, max-width, etc.) and the value (481px, 30em, etc.). If you specify the value only, ```min-width``` will be used by default (ideal if you follow a mobile-first approach). You can also change the default feature in the settings (see section below).
144
- * ```total-columns``` (optional) is the total number of columns to be used inside this media query. Changing the total number of columns will change the width, padding and margin percentages obtained using the ```span-column``` mixin.
137
+ * `query` contains the media feature (min-width, max-width, etc.) and the value (481px, 30em, etc.). If you specify the value only, `min-width` will be used by default (ideal if you follow a mobile-first approach). You can also change the default feature in the settings (see section below).
138
+ * `total-columns` (optional) is the total number of columns to be used inside this media query. Changing the total number of columns will change the width, padding and margin percentages obtained using the `span-column` mixin.
145
139
 
146
140
  ##### Example 1
147
141
 
@@ -220,9 +214,45 @@ The ```breakpoint()``` mixin allows you to use media-queries to modify both the
220
214
  }
221
215
  }
222
216
 
223
- For convenience, you can create a list variable to hold your media context (breakpoint/column-count) and use it throughout your code:
217
+ ##### Example 5
218
+
219
+ .my-class {
220
+ @include breakpoint(min-width 320px max-width 480px) {
221
+ font-size: 1.2em;
222
+ }
223
+ }
224
+
225
+ // Compiled CSS
226
+
227
+ @media screen and (min-width: 320px) and (max-width: 480px) {
228
+ .my-class {
229
+ font-size: 1.2em;
230
+ }
231
+ }
232
+
233
+ You can also use two ```@media``` features at the same time.
234
+
235
+ Here is a summary of possible argument combinations:
236
+
237
+ // YAY
238
+ @include breakpoint(480px);
239
+ @include breakpoint(max-width 480px);
240
+ @include breakpoint(min-width 320px max-width 480px);
241
+ @include breakpoint(480px, 4);
242
+ @include breakpoint(max-width 480px, 4);
243
+ @include breakpoint(min-width 320px max-width 480px, 4);
244
+ @include breakpoint(max-width 480px 4); // Shorthand syntax
245
+ @include breakpoint(min-width 320px max-width 480px 4); // Shorthand syntax
246
+
247
+ // NAY
248
+ @include breakpoint(480px 4);
249
+ @include breakpoint(max-width 4);
250
+ @include breakpoint(max-width, 4);
251
+ @include breakpoint(320px max-width 480px);
252
+
253
+ For convenience, you can create a new media context (breakpoint/column-count) with the help of the`new-breakpoint` mixin and use it throughout your code:
224
254
 
225
- $mobile: max-width 480px 4; // Use a 4 column grid in mobile devices (requires all three arguments to work)
255
+ $mobile: new-breakpoint(max-width 480px 4); // Use a 4 column grid in mobile devices
226
256
 
227
257
  .my-class {
228
258
  @include breakpoint($mobile) {
@@ -243,37 +273,57 @@ For convenience, you can create a list variable to hold your media context (brea
243
273
  margin-right: 0;
244
274
  }
245
275
  }
276
+ The `new-breakpoint` takes the same arguments as `breakpoint`.
246
277
 
247
- Here is a summary of possible argument combinations:
278
+ ### Visual grid
248
279
 
249
- // YAY
250
- @include breakpoint(480px);
251
- @include breakpoint(max-width 480px);
252
- @include breakpoint(480px, 4);
253
- @include breakpoint(max-width 480px, 4);
254
- @include breakpoint(max-width 480px 4); // Shorthand syntax
255
-
256
- // NAY
257
- @include breakpoint(480px 4);
258
- @include breakpoint(max-width 4);
259
- @include breakpoint(max-width, 4);
280
+ By setting `$visual-grid` to `true`, you can display the base grid in the background (default) or as an overlay. You can even change the color and opacity of the gridlines by overriding the default settings as detailed in the section below. Keep in mind that on Webkit, rounding errors in the fluid grid might result in the overlay being few pixels off.
260
281
 
282
+ The visual grid reflects the changes applied to the grid via the `new-breakpoint()` mixin.
261
283
 
262
284
  ### Changing the defaults
263
285
 
264
- All the default settings can be overridden, including ```$grid-columns``` and ```$max-width```. The complete list of settings can be found in the ```/settings``` subfolder. In order to override any of these settings, redefine the variable in your site-wide ```_variables.scss``` and make sure to import it *before* Neat (failing to do so will cause Neat to use the default values):
286
+ All the default settings can be overridden in your site-wide `_variables.scss`. Make sure to import this file *before* Neat (failing to do so will cause Neat to use the default values):
265
287
 
266
288
  @import "bourbon/bourbon";
267
289
  @import "variables";
268
290
  @import "neat/neat";
291
+
292
+ Here is the list of the available settings:
293
+
294
+ #### Grid settings
295
+
296
+ - `$column`: The width of a single column in `px` or `em`.
297
+ - `$gutter`: Space between each two columns in `px` or `em`.
298
+ - `$grid-columns`: Total number of columns in the base grid. Defaults to 12.
299
+ - `$max-width`: The maximum width of the outer container in `px` or `em`.
300
+
301
+ #### Visual grid settings
302
+
303
+ - `$visual-grid`: Show the base grid. Defaults to `false`.
304
+ - `$visual-grid-color`: Visual grid color. Defaults to `#EEEEEE`.
305
+ - `$visual-grid-index`: If set to `front`, the grid is overlaid on the content.
306
+ - `$visual-grid-opacity`: Visual grid opacity.
307
+
308
+ #### Other settings
309
+
310
+ - `$border-box-sizing`: Makes all elements have a `border-box` layout. Defaults to `true`.
311
+ - `$default-feature`: Default `@media` feature for the `breakpoint()` mixin. Defaults to `min-width`.
269
312
 
313
+ ### Browser support
314
+ - Firefox 3.5+
315
+ - Safari 4.0+
316
+ - Chrome 4.0+
317
+ - Opera 9.5+
318
+ - IE 9+ (Visual grid is IE10 only)
319
+ - IE 8 with [selectivizr](http://selectivizr.com) (no `breakpoint()` support)
270
320
 
271
321
  Credits
272
322
  ===
273
323
 
274
324
  ![thoughtbot](http://thoughtbot.com/images/tm/logo.png)
275
325
 
276
- Bourbon is maintained and funded by [thoughtbot, inc](http://thoughtbot.com/community). Tweet your questions or suggestions at [Kyle](https://twitter.com/kylefiedler) / [Reda](https://twitter.com/kaishin).
326
+ Bourbon is maintained and funded by [thoughtbot, inc](http://thoughtbot.com/community). Tweet your questions or suggestions at [@kaishin](https://twitter.com/kaishin) and [@kylefiedler](https://twitter.com/kylefiedler).
277
327
 
278
328
  License
279
329
  ===
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -3,16 +3,15 @@
3
3
  // Copyright (c) 2011 thoughtbot, inc.
4
4
 
5
5
  // Custom Functions
6
- @import "functions/line-height";
7
6
  @import "functions/px-to-em";
8
7
  @import "functions/grid";
8
+ @import "functions/helpers";
9
9
 
10
10
  // Default Settings
11
11
  @import "settings/grid";
12
- @import "settings/typography";
12
+ @import "settings/visual-grid";
13
13
 
14
14
  // The Grid
15
+ @import "grid/global-variables";
15
16
  @import "grid/grid";
16
-
17
- // Typography
18
- @import "typography/typography";
17
+ @import "grid/visual-grid";
@@ -0,0 +1,34 @@
1
+ @function is-even($int) {
2
+ @if $int%2 == 0 {
3
+ @return true;
4
+ }
5
+
6
+ @return false;
7
+ }
8
+
9
+ @function belongs-to($tested-item, $list) {
10
+ @each $item in $list {
11
+ @if $item == $tested-item {
12
+ @return true;
13
+ }
14
+ }
15
+
16
+ @return false;
17
+ }
18
+
19
+ @function new-breakpoint($query:$feature $value $columns, $total-columns: $grid-columns) {
20
+
21
+ @if length($query) == 1 {
22
+ $query: $default-feature nth($query, 1) $total-columns;
23
+ }
24
+
25
+ @else if length($query) == 2 or length($query) == 4 {
26
+ $query: append($query, $total-columns);
27
+ }
28
+
29
+ @if not belongs-to($query, $visual-grid-breakpoints) {
30
+ $visual-grid-breakpoints: append($visual-grid-breakpoints, $query, comma);
31
+ }
32
+
33
+ @return $query;
34
+ }
@@ -0,0 +1 @@
1
+ $parent-columns: $grid-columns !default;
@@ -26,6 +26,10 @@ $fg-max-width: $max-width;
26
26
  $columns: nth($span, 1);
27
27
  $container-columns: container-span($span);
28
28
 
29
+ @if $container-columns != $grid-columns {
30
+ $parent-columns: $container-columns;
31
+ }
32
+
29
33
  @if $display == table {
30
34
  display: table-cell;
31
35
  padding-right: flex-gutter($container-columns);
@@ -72,7 +76,7 @@ $fg-max-width: $max-width;
72
76
 
73
77
  // Shift
74
78
  @mixin shift($n-columns: 1) {
75
- margin-left: $n-columns * flex-grid(1) + $n-columns * flex-gutter();
79
+ margin-left: $n-columns * flex-grid(1, $parent-columns) + $n-columns * flex-gutter($parent-columns);
76
80
  }
77
81
 
78
82
 
@@ -145,8 +149,25 @@ $fg-max-width: $max-width;
145
149
  }
146
150
  }
147
151
 
152
+ @else if length($query) == 4 {
153
+ @media screen and (nth($query, 1): nth($query, 2)) and (nth($query, 3): nth($query, 4)) {
154
+ $default-grid-columns: $grid-columns;
155
+ $grid-columns: $total-columns;
156
+ @content;
157
+ $grid-columns: $default-grid-columns;
158
+ }
159
+ }
160
+
161
+ @else if length($query) == 5 {
162
+ @media screen and (nth($query, 1): nth($query, 2)) and (nth($query, 3): nth($query, 4)) {
163
+ $default-grid-columns: $grid-columns;
164
+ $grid-columns: nth($query, 5);
165
+ @content;
166
+ $grid-columns: $default-grid-columns;
167
+ }
168
+ }
169
+
148
170
  @else {
149
171
  @warn "Wrong number of arguments for breakpoint(). Read the documentation for more details.";
150
172
  }
151
173
  }
152
-
@@ -0,0 +1,66 @@
1
+ @mixin grid-column-gradient($values...) {
2
+ background-image: deprecated-webkit-gradient(linear, left top, left bottom, $values);
3
+ background-image: -webkit-linear-gradient(left, $values);
4
+ background-image: -moz-linear-gradient(left, $values);
5
+ background-image: -ms-linear-gradient(left, $values);
6
+ background-image: -o-linear-gradient(left, $values);
7
+ background-image: unquote("linear-gradient(left, #{$values})");
8
+ }
9
+
10
+ @function gradient-stops($grid-columns, $color: $visual-grid-color) {
11
+ $transparent: rgba(0,0,0,0);
12
+
13
+ $column-width: flex-grid(1, $grid-columns);
14
+ $gutter-width: flex-gutter($grid-columns);
15
+ $column-offset: $column-width;
16
+
17
+ $values: ($transparent 0, $color 0);
18
+
19
+ @for $i from 1 to $grid-columns*2 {
20
+ @if is-even($i) {
21
+ $values: append($values, $transparent $column-offset);
22
+ $values: append($values, $color $column-offset);
23
+ $column-offset: $column-offset + $column-width;
24
+ }
25
+
26
+ @else {
27
+ $values: append($values, $color $column-offset);
28
+ $values: append($values, $transparent $column-offset);
29
+ $column-offset: $column-offset + $gutter-width;
30
+ }
31
+ }
32
+
33
+ @return $values;
34
+ }
35
+
36
+ @if $visual-grid == true {
37
+ body:before {
38
+ content: '';
39
+ display: inline-block;
40
+ @include grid-column-gradient(gradient-stops($grid-columns));
41
+ height: 100%;
42
+ left: 0;
43
+ margin: 0 auto;
44
+ max-width: $max-width;
45
+ opacity: $visual-grid-opacity;
46
+ position: fixed;
47
+ right: 0;
48
+ width: 100%;
49
+
50
+ @if $visual-grid-index == back {
51
+ z-index: -1;
52
+ }
53
+
54
+ @else if $visual-grid-index == front {
55
+ z-index: 9999;
56
+ }
57
+
58
+ @each $breakpoint in $visual-grid-breakpoints {
59
+ @if $breakpoint != nil {
60
+ @include breakpoint($breakpoint) {
61
+ @include grid-column-gradient(gradient-stops($grid-columns));
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
@@ -1,6 +1,6 @@
1
- $column: golden-ratio(1em, 3) !default;
2
- $gutter: golden-ratio(1em, 1) !default;
3
- $grid-columns: 12 !default;
4
- $max-width: golden-ratio(1em, 9) !default;
5
- $border-box-sizing: true !default; // Makes all elements have border-box layout
6
- $default-feature: min-width;
1
+ $column: golden-ratio(1em, 3) !default; // Column width
2
+ $gutter: golden-ratio(1em, 1) !default; // Gutter between each two columns
3
+ $grid-columns: 12 !default; // Total number of columns in the grid
4
+ $max-width: em(1088) !default; // Max-width of the outer container
5
+ $border-box-sizing: true !default; // Makes all elements have a border-box layout
6
+ $default-feature: min-width; // Default @media feature for the breakpoint() mixin
@@ -0,0 +1,5 @@
1
+ $visual-grid: false !default; // Display the base grid
2
+ $visual-grid-color: #EEE !default;
3
+ $visual-grid-index: back !default; // Show grid behind content (back) or overlay it over the content (front)
4
+ $visual-grid-opacity: 0.4 !default;
5
+ $visual-grid-breakpoints: nil !default;
@@ -1,3 +1,3 @@
1
1
  module Neat
2
- VERSION = '0.4.2'
2
+ VERSION = '1.0.0.pre'
3
3
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.homepage = "https://github.com/thoughtbot/neat"
12
12
  s.summary = "A fluid grid framework on top of Bourbon"
13
13
  s.description = <<-DESC
14
- Neat is an open source fluid grid framework built on top of Bourbon with the aim of being easy enough to use out of the box and flexible enough to customize down the road.
14
+ Neat is an open source grid framework built on top of Bourbon with the aim of being easy enough to use out of the box and flexible enough to customize down the road.
15
15
  DESC
16
16
 
17
17
  s.rubyforge_project = "neat"
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
5
- prerelease:
4
+ version: 1.0.0.pre
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kyle Fiedler
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-08-31 00:00:00.000000000 Z
14
+ date: 2012-10-22 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: sass
@@ -77,8 +77,8 @@ dependencies:
77
77
  - - ! '>='
78
78
  - !ruby/object:Gem::Version
79
79
  version: '0'
80
- description: ! 'Neat is an open source fluid grid framework built on top of Bourbon
81
- with the aim of being easy enough to use out of the box and flexible enough to customize
80
+ description: ! 'Neat is an open source grid framework built on top of Bourbon with
81
+ the aim of being easy enough to use out of the box and flexible enough to customize
82
82
  down the road.
83
83
 
84
84
  '
@@ -92,14 +92,16 @@ files:
92
92
  - Gemfile
93
93
  - LICENSE
94
94
  - README.md
95
+ - Rakefile
95
96
  - app/assets/stylesheets/_neat.scss
96
97
  - app/assets/stylesheets/functions/_grid.scss
97
- - app/assets/stylesheets/functions/_line-height.scss
98
+ - app/assets/stylesheets/functions/_helpers.scss
98
99
  - app/assets/stylesheets/functions/_px-to-em.scss
100
+ - app/assets/stylesheets/grid/_global-variables.scss
99
101
  - app/assets/stylesheets/grid/_grid.scss
102
+ - app/assets/stylesheets/grid/_visual-grid.scss
100
103
  - app/assets/stylesheets/settings/_grid.scss
101
- - app/assets/stylesheets/settings/_typography.scss
102
- - app/assets/stylesheets/typography/_typography.scss
104
+ - app/assets/stylesheets/settings/_visual-grid.scss
103
105
  - lib/neat.rb
104
106
  - lib/neat/engine.rb
105
107
  - lib/neat/version.rb
@@ -120,13 +122,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
122
  required_rubygems_version: !ruby/object:Gem::Requirement
121
123
  none: false
122
124
  requirements:
123
- - - ! '>='
125
+ - - ! '>'
124
126
  - !ruby/object:Gem::Version
125
- version: '0'
127
+ version: 1.3.1
126
128
  requirements: []
127
129
  rubyforge_project: neat
128
- rubygems_version: 1.8.22
130
+ rubygems_version: 1.8.24
129
131
  signing_key:
130
132
  specification_version: 3
131
133
  summary: A fluid grid framework on top of Bourbon
132
134
  test_files: []
135
+ has_rdoc:
@@ -1,3 +0,0 @@
1
- $body-font-size: 1em !default;
2
- $body-line-height: golden-ratio(1em, 1) !default;
3
- $body-font-family: $helvetica !default;
@@ -1,4 +0,0 @@
1
- body {
2
- font: $body-font-size $body-font-family;
3
- line-height: $body-line-height;
4
- }