shelves 0.6.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,56 +1,11 @@
1
- Shelves CSS Grid
2
- ================
1
+ Shelves CSS Grid Framework
2
+ ==========================
3
3
 
4
- **The only responsive, fluid CSS grid with infinitely nestable columns.**
4
+ **The only responsive, fluid CSS grid framework with infinitely nestable columns.**
5
5
 
6
- [See the Demo](http://shelves.petebrowne.com/)
7
-
8
- TODO: Add longer description & Feature list.
9
-
10
- Installation
11
- ------------
12
-
13
- ### For CSS Users
14
-
15
- Download the latest distribution of [the CSS file](https://raw.github.com/petebrowne/shelves/master/css/shelves.css) and go to town.
16
-
17
- ### For Sass Users (Compass & Rails)
18
-
19
- Add the shelves gem to your Gemfile and import it:
20
-
21
- ``` ruby
22
- # ...
23
- gem 'shelves'
24
- # ...
25
- ```
26
-
27
- ``` scss
28
- // @import "shelves"; // Import just the mixins
29
- @import "shelves-grid"; // Import mixins & default grid
30
- ```
31
-
32
- Custom CSS Build
33
- ----------------
34
-
35
- To customize the CSS without using Sass, you can use the command line tool:
36
-
37
- ``` bash
38
- $ gem install shelves
39
- $ shelves --width 1140px --columns 16 > grid.css
40
- ```
41
-
42
- Run width `--help` to see all of the available options:
43
-
44
- ``` bash
45
- $ shelves --help
46
- ```
47
-
48
- Usage
49
- -----
50
-
51
- TODO...
6
+ [Demo & Documentation](http://shelves.whoisartifex.com/)
52
7
 
53
8
  Copyright
54
9
  ---------
55
10
 
56
- Copyright (c) 2012 [Pete Browne](http://petebrowne.com). See LICENSE for details.
11
+ Copyright (c) 2013 [Artifex](http://whoisartifex.com/). See LICENSE for details.
data/component.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shelves",
3
- "version": "0.6.0",
3
+ "version": "1.0.0",
4
4
  "main": ["css/shelves.css", "scss/shelves.scss"],
5
5
  "ignore": [
6
6
  "*.gemspec",
data/lib/shelves/cli.rb CHANGED
@@ -48,6 +48,12 @@ BANNER
48
48
  desc 'Do not include nested columns.'
49
49
  end
50
50
 
51
+ option 'skip-desktop' do
52
+ short '-D'
53
+ long '--skip-desktop'
54
+ desc 'Do not include desktop columns.'
55
+ end
56
+
51
57
  option 'skip-tablet' do
52
58
  short '-T'
53
59
  long '--skip-tablet'
@@ -135,6 +141,16 @@ BANNER
135
141
  separator ''
136
142
  separator 'Advanced Options:'
137
143
 
144
+ option 'skip-center' do
145
+ long '--skip-center'
146
+ desc 'Do not include center column helper.'
147
+ end
148
+
149
+ option 'skip-visibility' do
150
+ long '--skip-visibility'
151
+ desc 'Do not include visibility helpers.'
152
+ end
153
+
138
154
  option 'skip-ie7-support' do
139
155
  long '--skip-ie7-support'
140
156
  desc 'Skip legacy support for IE7.'
@@ -146,17 +162,17 @@ BANNER
146
162
  end
147
163
 
148
164
  option 'skip-suffixes' do
149
- long '--skip-suffix'
165
+ long '--skip-suffixes'
150
166
  desc 'Do not include suffix classes.'
151
167
  end
152
168
 
153
169
  option 'skip-pushes' do
154
- long '--skip-push'
170
+ long '--skip-pushes'
155
171
  desc 'Do not include push classes.'
156
172
  end
157
173
 
158
174
  option 'skip-pulls' do
159
- long '--skip-pull'
175
+ long '--skip-pulls'
160
176
  desc 'Do not include pull classes.'
161
177
  end
162
178
 
@@ -243,8 +259,7 @@ module Shelves
243
259
  <% settings.each do |setting, value| %>
244
260
  $shelves-<%= setting %>: <%= value %>;
245
261
  <% end %>
246
- @import "shelves";
247
- @include shelves;
262
+ @import "shelves-grid";
248
263
  TEMPLATE
249
264
  template.result(binding)
250
265
  end
@@ -254,6 +269,7 @@ TEMPLATE
254
269
  settings.each do |setting, value|
255
270
  if setting =~ /^skip-(\w*)$/
256
271
  setting = $1
272
+ setting = "#{setting}-columns" if %w(desktop tablet mobile).include?(setting)
257
273
  value = false
258
274
  end
259
275
  normalized_settings[setting] = value
@@ -1,3 +1,3 @@
1
1
  module Shelves
2
- VERSION = '0.6.0'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -1,2 +1,147 @@
1
1
  @import "shelves";
2
- @include shelves;
2
+
3
+ @include shelves-base;
4
+
5
+ // Mobile
6
+ // ----------------------------------------------------------------------------
7
+
8
+ @if $shelves-mobile-columns != false {
9
+ @include with-mobile-grid {
10
+ %shelves-mobile-column-base {
11
+ @include column-base;
12
+ @include column-gutter;
13
+
14
+ #{class-selector($shelves-row-name)} &:first-child {
15
+ @extend %shelves-mobile-first-column;
16
+ }
17
+ }
18
+
19
+ %shelves-mobile-first-column {
20
+ @include reset-column-gutter;
21
+ }
22
+
23
+ #{class-selector($shelves-first-mobile-column-name)} {
24
+ @extend %shelves-mobile-first-column;
25
+ }
26
+
27
+ @include shelves-columns(
28
+ $extend: "shelves-mobile-column-base",
29
+ $prefixes: $shelves-mobile-prefixes,
30
+ $suffixes: $shelves-mobile-suffixes,
31
+ $pushes: $shelves-mobile-pushes,
32
+ $pulls: $shelves-mobile-pulls,
33
+ $column-name: $shelves-mobile-column-name,
34
+ $prefix-name: $shelves-mobile-prefix-name,
35
+ $suffix-name: $shelves-mobile-suffix-name,
36
+ $push-name: $shelves-mobile-push-name,
37
+ $pull-name: $shelves-mobile-pull-name
38
+ );
39
+ }
40
+ }
41
+
42
+ // Tablet
43
+ // ----------------------------------------------------------------------------
44
+
45
+ @if $shelves-tablet-columns != false {
46
+ @include on-tablet-up {
47
+ %shelves-tablet-column-base {
48
+ @include column-base;
49
+ @include column-gutter;
50
+
51
+ #{class-selector($shelves-row-name)} &:first-child {
52
+ @extend %shelves-tablet-first-column;
53
+ }
54
+ }
55
+
56
+ %shelves-tablet-first-column {
57
+ @include reset-column-gutter;
58
+ }
59
+
60
+ #{class-selector($shelves-first-tablet-column-name)} {
61
+ @extend %shelves-tablet-first-column;
62
+ }
63
+
64
+ @include shelves-columns(
65
+ $extend: "shelves-tablet-column-base",
66
+ $prefixes: $shelves-tablet-prefixes,
67
+ $suffixes: $shelves-tablet-suffixes,
68
+ $pushes: $shelves-tablet-pushes,
69
+ $pulls: $shelves-tablet-pulls,
70
+ $column-name: $shelves-tablet-column-name,
71
+ $prefix-name: $shelves-tablet-prefix-name,
72
+ $suffix-name: $shelves-tablet-suffix-name,
73
+ $push-name: $shelves-tablet-push-name,
74
+ $pull-name: $shelves-tablet-pull-name
75
+ );
76
+ }
77
+ }
78
+
79
+ // Desktop
80
+ // ----------------------------------------------------------------------------
81
+
82
+ @if $shelves-desktop-columns != false {
83
+ @include on-desktop {
84
+ %shelves-desktop-column-base {
85
+ @include column-base;
86
+ @include column-gutter;
87
+
88
+ #{class-selector($shelves-row-name)} &:first-child {
89
+ @extend %shelves-first-desktop-column;
90
+ }
91
+ }
92
+
93
+ %shelves-first-desktop-column {
94
+ @include reset-column-gutter;
95
+ }
96
+
97
+ #{class-selector($shelves-first-desktop-column-name)} {
98
+ @extend %shelves-first-desktop-column;
99
+ }
100
+
101
+ @include shelves-columns(
102
+ $extend: "shelves-desktop-column-base",
103
+ $prefixes: $shelves-prefixes,
104
+ $suffixes: $shelves-suffixes,
105
+ $pushes: $shelves-pushes,
106
+ $pulls: $shelves-pulls
107
+ );
108
+
109
+ // Nested Desktop Columns
110
+
111
+ @if $shelves-nested-columns != false {
112
+ @for $i from 1 to $shelves-desktop-columns - 1 {
113
+ // Loop background through the columns
114
+ // to cascade the nested column properties.
115
+ $i: $shelves-desktop-columns - $i;
116
+
117
+ #{class-selector($shelves-desktop-column-name $i)} {
118
+ %shelves-nested-column-#{$i}-base {
119
+ @include column-gutter($i);
120
+ }
121
+
122
+ @include shelves-columns(
123
+ $extend: "shelves-nested-column-#{$i}-base",
124
+ $context: $i,
125
+ $prefixes: $shelves-nested-prefixes,
126
+ $suffixes: $shelves-nested-suffixes,
127
+ $pushes: $shelves-nested-pushes,
128
+ $pulls: $shelves-nested-pulls
129
+ );
130
+ }
131
+ }
132
+ }
133
+ }
134
+ }
135
+
136
+ @if $shelves-center {
137
+ #{class-selector($shelves-row-name)} #{class-selector($shelves-center-column-name)} {
138
+ @include center-column;
139
+ }
140
+ }
141
+
142
+ // Visibility Helpers
143
+ // ----------------------------------------------------------------------------
144
+
145
+ @if $shelves-visibility {
146
+ @include shelves-visibility-helpers;
147
+ }
data/scss/shelves.scss CHANGED
@@ -7,6 +7,6 @@ The only responsive, fluid CSS grid with infinitely nestable columns.
7
7
  Copyright (c) 2012, Pete Browne
8
8
  */
9
9
 
10
- @import "shelves/settings";
11
10
  @import "shelves/functions";
11
+ @import "shelves/variables";
12
12
  @import "shelves/mixins";
@@ -9,8 +9,8 @@
9
9
  // $gutter - The width of the gutter in the root context (in %).
10
10
  // Defaults to the value of $shelves-gutter.
11
11
  //
12
- @function column-width(
13
- $context: null,
12
+ @function single-column-width(
13
+ $context: $shelves-context,
14
14
  $total: $shelves-columns,
15
15
  $gutter: $shelves-gutter) {
16
16
  $context: $total !default;
@@ -19,74 +19,73 @@
19
19
  @return 100%;
20
20
  }
21
21
  @else if $context >= $total {
22
- $column-gutter: column-gutter($total: $total, $gutter: $gutter);
22
+ $column-gutter: column-gutter($context: null, $total: $total, $gutter: $gutter);
23
23
  @return (100% - ($total - 1) * $column-gutter) / $total;
24
24
  }
25
25
  @else {
26
- $column-width: column-width($total: $total, $gutter: $gutter);
27
- $context-width: columns-width($n: $context, $total: $total, $gutter: $gutter);
26
+ $column-width: single-column-width($context: null, $total: $total, $gutter: $gutter);
27
+ $context-width: column-width($n: $context, $context: null, $total: $total, $gutter: $gutter);
28
28
  @return $column-width * (100% / $context-width);
29
29
  }
30
30
  }
31
31
 
32
- // Returns the width of the gutter as a percentage. If given a $context,
33
- // this returns the gutter width relative to that number of columns.
32
+ // Returns the total width (including gutters) of the given
33
+ // number of columns. If given a $context, this returns the
34
+ // width relative to that number of columns.
34
35
  //
35
- // $context - The number of columns encapsulating the gutter.
36
+ // $n - The number of columns to measure.
37
+ // $context - The number of columns encapsulating the columns.
36
38
  // Defaults to the the value of $total.
37
39
  // $total - The total number of columns in the grid.
38
40
  // Defaults to the value of $shelves-columns.
39
41
  // $gutter - The width of the gutter in the root context (in %).
40
42
  // Defaults to the value of $shelves-gutter.
41
43
  //
42
- @function column-gutter(
43
- $context: null,
44
+ @function column-width(
45
+ $n,
46
+ $context: $shelves-context,
44
47
  $total: $shelves-columns,
45
48
  $gutter: $shelves-gutter) {
46
49
  $context: $total !default;
47
50
 
48
- @if $context <= 1 {
49
- @return 0%;
51
+ @if $n <= 1 {
52
+ @return single-column-width($context, $total, $gutter);
50
53
  }
51
- @else if $context >= $total {
52
- @return $gutter;
54
+ @else if $n >= $context {
55
+ @return 100%;
53
56
  }
54
57
  @else {
55
- $context-width: columns-width($n: $context, $total: $total);
56
- @return $gutter * (100% / $context-width);
58
+ $column-width: single-column-width($context, $total, $gutter);
59
+ $column-gutter: column-gutter($context, $total, $gutter);
60
+ @return $column-width * $n + $column-gutter * ($n - 1);
57
61
  }
58
62
  }
59
63
 
60
- // Returns the total width (including gutters) of the given
61
- // number of columns. If given a $context, this returns the
62
- // width relative to that number of columns.
64
+ // Returns the width of the gutter as a percentage. If given a $context,
65
+ // this returns the gutter width relative to that number of columns.
63
66
  //
64
- // $n - The number of columns to measure.
65
- // $context - The number of columns encapsulating the columns.
67
+ // $context - The number of columns encapsulating the gutter.
66
68
  // Defaults to the the value of $total.
67
69
  // $total - The total number of columns in the grid.
68
70
  // Defaults to the value of $shelves-columns.
69
71
  // $gutter - The width of the gutter in the root context (in %).
70
72
  // Defaults to the value of $shelves-gutter.
71
73
  //
72
- @function columns-width(
73
- $n,
74
- $context: null,
74
+ @function column-gutter(
75
+ $context: $shelves-context,
75
76
  $total: $shelves-columns,
76
77
  $gutter: $shelves-gutter) {
77
78
  $context: $total !default;
78
79
 
79
- @if $n <= 1 {
80
- @return column-width($context, $total, $gutter);
80
+ @if $context <= 1 {
81
+ @return 0%;
81
82
  }
82
- @else if $n >= $context {
83
- @return 100%;
83
+ @else if $context >= $total {
84
+ @return $gutter;
84
85
  }
85
86
  @else {
86
- $column-width: column-width($context, $total, $gutter);
87
- $column-gutter: column-gutter($context, $total, $gutter);
88
-
89
- @return $column-width * $n + $column-gutter * ($n - 1);
87
+ $context-width: column-width($n: $context, $context: null, $total: $total);
88
+ @return $gutter * (100% / $context-width);
90
89
  }
91
90
  }
92
91
 
@@ -94,43 +93,63 @@
94
93
  // number of columns. If given a $context, this returns the
95
94
  // distance relative to that number of columns.
96
95
  //
97
- // $n - The number of columns to measure.
98
- // $context - The number of columns encapsulating the columns.
99
- // Defaults to the the value of $total.
100
- // $total - The total number of columns in the grid.
101
- // Defaults to the value of $shelves-columns.
102
- // $gutter - The width of the gutter in the root context (in %).
103
- // Defaults to the value of $shelves-gutter.
96
+ // $n - The number of columns to measure.
97
+ // $context - The number of columns encapsulating the columns.
98
+ // Defaults to the the value of $total.
99
+ // $total - The total number of columns in the grid.
100
+ // Defaults to the value of $shelves-columns.
101
+ // $gutter - The width of the gutter in the root context (in %).
102
+ // Defaults to the value of $shelves-gutter.
103
+ // $with-gutter - Include an extra gutter in the calculation.
104
+ // Defaults to true.
104
105
  //
105
- @function columns-distance(
106
+ @function column-distance(
106
107
  $n,
107
- $context: null,
108
+ $context: $shelves-context,
108
109
  $total: $shelves-columns,
109
- $gutter: $shelves-gutter) {
110
- @return columns-width($n, $context, $total, $gutter) + column-gutter($context, $total, $gutter);
110
+ $gutter: $shelves-gutter,
111
+ $with-gutter: true) {
112
+ $distance: column-width($n, $context, $total, $gutter);
113
+ @if $with-gutter {
114
+ $distance: $distance + column-gutter($context, $total, $gutter);
115
+ }
116
+ @return $distance;
111
117
  }
112
118
 
113
- // Returns a column selector with the given class name,
114
- // appended with the given index.
119
+ // Creates a class name by joining the parts of a list with the default
120
+ // $shelves-separator.
115
121
  //
116
- // $class-name - The class name to build the selector from.
117
- // It should NOT have a preceding ".".
118
- // $index - The index to append at the end. It will
119
- // be separated by $separator.
120
- // $separator - The separator between the class name and index.
121
- // Defaults to $shelves-separator.
122
+ // $list - The list of items to join.
122
123
  //
123
- @function column-selector($class-name, $index, $separator: $shelves-separator) {
124
- @return ".#{$class-name}#{$separator}#{$index}";
124
+ @function class-name($list) {
125
+ @return implode($list, $shelves-separator);
125
126
  }
126
127
 
127
- // Returns a selector that will select all columns with the given prefix.
128
+ // Creates an actual class selector by prefixing it with a ".".
128
129
  //
129
- // $class-name - The class name to build the selector from.
130
- // It should NOT have a preceding ".".
131
- // $separator - The separator between the class name and index.
132
- // Defaults to $shelves-separator.
130
+ // $name - A string or list of strings to create a class name from.
133
131
  //
134
- @function columns-selector($class-name, $separator: $shelves-separator) {
135
- @return "[class*=\"#{$class-name}#{$separator}\"]";
132
+ @function class-selector($name) {
133
+ @return ".#{class-name($name)}";
134
+ }
135
+
136
+ // Creates a string by joining the parts of a list with the given separator.
137
+ //
138
+ // Note: This uses the PHP-style "implode" because Sass already uses "join"
139
+ // for concatenation.
140
+ //
141
+ // $list - The list of items to join.
142
+ // $separator - The string to join with. Defaults to an empty string ("").
143
+ //
144
+ @function implode($list, $separator: "") {
145
+ $length: length($list);
146
+ $output: nth($list, 1);
147
+
148
+ @for $i from 2 through $length {
149
+ $item: nth($list, $i);
150
+ @if $item != null {
151
+ $output: "#{$output}#{$separator}#{$item}";
152
+ }
153
+ }
154
+ @return $output;
136
155
  }